Skip to main content

How to Access the A/B Test Group Index for Custom Code Injection

Written by Kelly at ABConvert
Updated today

If you’d like to inject custom JavaScript or CSS into your A/B test variants, you can use the test group index stored in the browser’s localStorage to conditionally apply changes. This is useful for developers or advanced users who want to apply logic based on whether a visitor is in the control or test group.

How it works

Our A/B testing script assigns visitors to a test group based on your test configuration and stores this information in the browser’s local storage. This value can be read and used in your custom scripts or styles.

Group index reference

Group Index

Description

0

Original group

1

Variant 1

2

Variant 2

3

Variant 3

4

Variant 4

Accessing the test group index

You can read the test metadata from the browser’s localStorage. Each test stores data under a specific key and includes information like experimentId, groupIndex, and sometimes startTime.

⚠️ If you are using the new 2.0 version, please read the next section.

Test Type

Key

Value

Price test (cart transform)

abconvert-experiment-to-group-index

{ experimentId, groupIndex }

Price test (duplicate variant)

abconvert-price-test-experiment-to-group-index

{ experimentId, groupIndex }

Url redirect test

abconvert-url-redirect-test-${experimentId}

{ experimentId, groupIndex, startTime }

Template test

abconvert-template-test-${experimentId}

{ experimentId, groupIndex, startTime }

Theme test

abconvert-theme-test-${experimentId}

{ experimentId, groupIndex, startTime }

Delivery customization test

abconvert-delivery-customization-test-experiment-to-group-index

{ experimentId, groupIndex }

Payment customization test

abconvert-payment-customization-test-experiment-to-group-index

{ experimentId, groupIndex }

Checkout UI test

abconvert-checkout-ui-test-experiment-to-group-index

{ experimentId, groupIndex }

Value explanation

  1. experimentId: This is the unique identifier of the test in our database. It helps track and differentiate between various experiments running on your store.

  2. startTime (included in some tests): The timestamp (in milliseconds) representing when the test started running on your store.

Accessing the test group index for 2.0 version

You can read the test metadata from the browser’s localStorage. Each test stores data under a specific key and includes information like experimentId, groupIndex, and sometimes startTime.

Last updated: Apr 1, 2026

Test Type

Key

Value

Price test (cart transform)

abconvert-experiment-to-group-index

{ experimentId, groupIndex }

Url redirect test

abconvert-url-redirect-test-${experimentId}

{ experimentId, groupIndex, startTime }

Template test

abconvert-template-test-${experimentId}

{ experimentId, groupIndex, startTime }

Theme test

abconvert-theme-test-${experimentId}

{ experimentId, groupIndex, startTime }

Visual editor test

abconvert.visual-editor.${experimentId}

{ experimentId, groupIndex, startTime }

Shipping test v2

abconvert.shipping.v2

{ assignments: [{ experimentId, groupIndex }], timestamp }

Did this answer your question?