getVisitorData

The getVisitorData() method is the primary way to check the current visitor's test state.

The getVisitorData() method takes 0 arguments, and returns a ExternalVisitorData representing whether the visitor's current test state.

ExternalVisitorData

Name
Type
Description

visitor

Visitor details

visitorTests

List of test information visitor is associated with

Visitor

Name
Type
Description

id

string

The unique id of the visitor

createdAt

Date

The date and time the visitor was created

shopifyAnalyticsId

string | null

The analytics id of the visitor defined by Shopify

device

"desktop" | "mobile"

The device used by the visitor

ExternalTestRelation

Name
Type
Description

createdAt

Date

The date and time when the visitor was associated with the test

testId

string

The id of the test a visitor is associated with

hypothesisId

string

The id of the test hypothesis a visitor is associated with

isThemeTest

boolean

Whether or not the test a visitor is associated with is a theme test

themeId

number | undefined

The themeId a visitor is associated with within a theme test

isSaved

boolean

Whether or not the visitor information has been saved to Shoplift

isInvalid

boolean | undefined

Whether or not a visitor and test association was attempted to be created during a test's paused or ended period

Example

const visitorData = window.shoplift.getVisitorData();
// Segment example
visitorData.visitorTests.forEach(vt => {
 analytics.track("Test Participation", {
    "shoplift_analytics_id": visitorData.shoplifyAnalyticsId,
    "test_id": vt.testId,
    "hypothesisId", vt.hypothesisId
  });
});

Last updated