> For the complete documentation index, see [llms.txt](https://docs.shoplift.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shoplift.ai/test/javascript-api/core-api-reference/ishypothesisactive.md).

# isHypothesisActive

### Check Test Variant Assignment

The isHypothesisActive() method is the core of the Shoplift JavaScript API. It determines whether the current visitor is assigned to the variant (B) or control (A) group of your A/B test and is used in 90% of all Shoplift implementations.

### Method Signature

```typescript
isHypothesisActive(hypothesisId: string): Promise<boolean>
```

#### Parameters

| Parameter    | Type   | Required | Description                                                             |
| ------------ | ------ | -------- | ----------------------------------------------------------------------- |
| hypothesisId | string | Yes      | The unique identifier for your test variant from the Shoplift dashboard |

#### Returns

| Type              | Description                                                                    |
| ----------------- | ------------------------------------------------------------------------------ |
| Promise\<boolean> | Resolves to true if the visitor is in the variant (B), false if in control (A) |

### Basic Usage

```javascript
// Simple A/B test
const isVariant = await window.shoplift.isHypothesisActive('aa800953-3e22-4335-a53b-50f61db17538');

if (isVariant) {
  // Visitor sees variant (B)
  showVariantExperience();
} else {
  // Visitor sees control (A)
  showControlExperience();
}
```

### How It Works

The behavior of `isHypothesisActive()` depends on your test configuration:

#### Automatic Trigger Tests

For tests with automatic triggers, visitors are assigned immediately on page load:

1. Page loads → Visitor automatically assigned to A or B
2. Your code calls isHypothesisActive() → Returns existing assignment
3. Assignment is already tracked in analytics

#### Manual Trigger Tests

For tests with manual triggers, visitors are only assigned on the first call:

1. Page loads → No assignment yet
2. First isHypothesisActive() call → Assigns visitor to A or B and returns result
3. Subsequent calls → Return cached assignment

### Return Value Scenarios

The method returns `true` when:

* Visitor is assigned to the variant (B)
* URL parameter forces this hypothesis (`?slVariant=hypothesis-id`)
* URL parameter forces all variants (`?slVariant=true`)

The method returns `false` when:

* Visitor is assigned to control (A)
* Test is inactive or paused
* Visitor doesn't meet targeting criteria
* Hypothesis ID is invalid or not found
* An error occurs (fails safe to control)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.shoplift.ai/test/javascript-api/core-api-reference/ishypothesisactive.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
