tys.experiment()
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>;Returns
Section titled “Returns”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).
experimentIdstringRequiredarmExperimentArmRequiredvisitorIdstringRequiredThe anonymous visitor ID: save it with the order (visitor_id in POST /v1/orders).
Example
Section titled “Example”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;await tys.orders.create({ id: "order_1042", visitor_id: cart.attributes.tys_visitor_id, // from tys.experiment() in the browser // …lines, currency});See also
Section titled “See also”Was this page helpful?
Thank you. We read every answer.