> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abconvert.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Read the visitor's test group

> Read which test group a visitor is in, to keep your storefront consistent with a test or to send the test group to another tool.

An assignment is the test group ABConvert put the visitor in. Read it when your own code needs to know.

The samples use `abconvert`, the client your [stack guide](/headless-sdk/overview#pick-your-stack) creates on the server, and `useABConvert()` in a component.

## Read an assignment

Use this to keep your storefront consistent with a test. To render a different version of a page per test group, see [Feature tests](/headless-sdk/feature-tests) (coming soon).

Read it on the server, or in the browser in a component. Both use the same method.

<CodeGroup>
  ```ts Server theme={null}
  const assignment = abconvert.getAssignment('49603');

  // Show the banner to every test group except Control
  const showBanner = assignment ? !assignment.testGroup.control : false;
  ```

  ```tsx Browser (component) theme={null}
  // components/FreeShippingBanner.tsx
  import { useABConvert } from '@abconvert/headless/react';

  export function FreeShippingBanner() {
    const { getAssignment } = useABConvert();
    const assignment = getAssignment('49603');

    // Show the banner to every test group except Control
    if (!assignment || assignment.testGroup.control) return null;
    return <Banner>Free shipping on every order</Banner>;
  }
  ```
</CodeGroup>

`'49603'` is the test ID shown in the ABConvert admin. `getAssignment` returns `null` when the visitor is not in the test. `getAssignments()` returns every assignment for the visitor.

## Send test groups to another tool

Pass `onAssignment` to the provider. It runs in the browser once the visitor allows analytics: once for each test they are in, on every page load.

```tsx Browser (provider) theme={null}
<ABConvertProvider
  pageState={pageState}
  onAssignment={(assignment) => {
    // Send one event per test to your analytics tool
    analytics.track('ABConvert test group', {
      testId: assignment.experimentId,
      testGroupIndex: assignment.testGroup.index,
    });
  }}
>
  {children}
</ABConvertProvider>
```

The provider also fires the `abconvert:assignment-ready` event on `window`, at the same moment. It is the event ABConvert fires on a theme. A tag manager trigger built on it keeps working. See [Events](/api-reference/browser-api-reference#events).

Neither runs for a forced or preview assignment.

## Common mistakes

* **Using `testGroup.name` as an identifier.** The name is a display label that can change while the test runs. The fix: send `testGroup.index` to other tools and branch on `testGroup.control` in your code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.