Skip to content

tys.experiment()

Method@tryyoursize/sdk

The visitor’s A/B holdout assignment when the store runs one (null otherwise). Save visitorId with the order (POST /v1/orders visitor_id) so returns are attributed to the right arm.

experiment(): Promise<ExperimentAssignment | null>;

Promise<ExperimentAssignment | null>: The assignment, or null when the store runs no A/B holdout (or the API cannot be reached: then everyone sees TryYourSize).

experimentIdstringRequired
armExperimentArmRequired
visitorIdstringRequired

The anonymous visitor ID: save it with the order (visitor_id in POST /v1/orders).

const a = await tys.experiment();
// Keep it with the cart; your server sends it with the order.
if (a) cart.attributes.tys_visitor_id = a.visitorId;

Was this page helpful?