DocsThe visitor token

The visitor token

The opaque token that ties a payment to the visitor who saw a variant: how to get it, which checkout field carries it, and what happens without it.

On this page

Why a token#

A payment happens at a payment processor, often on a page that is not yours and after the visitor has left your site for a moment. To credit the revenue to the variant that visitor saw, the payment has to carry something that points back to the visit. That is the visitor token: a random value your page asks us for, passes through checkout, and that arrives again with the payment.

The token identifies no person. It carries no name, e-mail address, phone number or address, and we never ask for any of them to match a payment.

No token, still counted

A payment that arrives without a token, or with one that does not match, is still recorded: as unmatched revenue at site level. It counts in the site totals for reporting and is never used to decide which variant wins.

What a token is#

  • It is lvt_ followed by 32 random hexadecimal characters, 36 characters in all, for example lvt_0123456789abcdef0123456789abcdef. That fits the shortest payment reference field we know of (40 characters).
  • It is random. It is not derived from the visitor id, from an e-mail address or from anything else about the person, and it cannot be decoded.
  • We store only its SHA-256 hash, with the visitor id, the site and an expiry. Looking a token up is the only way to learn who it belongs to.
  • It expires with the attribution window of the site: 30 days by default, between 1 and 90. Expired tokens are deleted.
  • It matches one payment to one exposure on one site. It is not an identifier across sites, and a visitor holds at most 5 live tokens per site.

Getting the token in the page#

The snippet asks for a token only when your page wants one, and only for a visitor it is allowed to track. Two ways to use it:

From JavaScript

lift.token() returns a promise that resolves to the token, or to null. It never rejects and settles within 3 seconds at the latest. Pass the value to your own server, which forwards it to the processor.

Reading the token before checkoutjs
// In the page, before the visitor pays. Resolves to the token or null; never rejects.
const token = await lift.token();

await fetch('/api/checkout', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  // Send it to YOUR server, which passes it on to the payment processor.
  body: JSON.stringify({ cart, lift_token: token }),
});

In a form

Put data-lift-token on an input and the snippet fills it with the token when the input is empty:

A hidden field the snippet fillshtml
<form method="post" action="/checkout">
  <!-- Lift fills this in when the visitor may be tracked. -->
  <input type="hidden" name="lift_token" data-lift-token>
  <!-- … your fields … -->
</form>

On a form_submit goal the snippet also adds a hidden lift_token field by itself, with these rules. It never edits or replaces a field you already have:

  • The form must use method="post" (a field in a GET form would land in the URL).
  • The form must post to the same origin and must not contain a password field.
  • A form without a goal match can opt in with data-lift-token, and any form can opt out with data-lift-token="off".
  • A control already named lift_token is left exactly as it is.

When there is no token

lift.token() resolves to null, and no hidden field is added, when the visitor must not be tracked: Do Not Track or Global Privacy Control on a site that honors them, or no consent on a site in opt-in mode. It is also null when the request fails. The token is kept in the first-party cookie _lift_t (mirrored in local storage) and is deleted with the rest of the snippet's storage when consent is withdrawn. See Consent and privacy.

Carrying it through checkout#

Your server puts the token where the processor passes it back with the payment. Each carrier below is the one the connector reads; if the processor you use is not listed, send the token to a generic connection or to the conversions API yourself.

ProcessorCarrier
Stripe Checkoutclient_reference_id of the Checkout Session, or metadata.lift_token
Stripe Payment Linksadd ?client_reference_id=<token> to the link
Stripe PaymentIntents (API mode)metadata.lift_token
Squarethe payment's reference_id, or anywhere in its note
PayPalcustom_id of the purchase unit
Housecall ProThe job description, notes or tags (no custom field is documented to reach the webhook); your mapping reads it from there
Anything elseA field of the JSON you post to your connection, or visitorToken in the conversions API

Stripe

Checkout Sessionjs
// On your server, with the token your page sent you.
const session = await stripe.checkout.sessions.create({
  mode: 'payment',
  line_items: [{ price: 'price_123', quantity: 1 }],
  success_url: 'https://www.example.com/thanks',
  // Either carrier is read; client_reference_id wins when both are set.
  client_reference_id: token,
  metadata: { lift_token: token },
});
Payment Linktext
https://buy.stripe.com/YOUR_LINK?client_reference_id=lvt_0123456789abcdef0123456789abcdef
PaymentIntent (API mode)js
const intent = await stripe.paymentIntents.create({
  amount: 4999,
  currency: 'usd',
  metadata: { lift_token: token },
});

Square

Order metadata is not part of a payment event, so it cannot carry the token. Use the payment's reference_id (up to 40 characters) or its note.

CreatePaymentjson
{
  "source_id": "…",
  "idempotency_key": "…",
  "amount_money": { "amount": 4999, "currency": "USD" },
  "reference_id": "lvt_0123456789abcdef0123456789abcdef"
}

PayPal

Create orderjson
{
  "intent": "CAPTURE",
  "purchase_units": [
    {
      "amount": { "currency_code": "USD", "value": "49.99" },
      "custom_id": "lvt_0123456789abcdef0123456789abcdef"
    }
  ]
}

Housecall Pro

Put the token in text the job carries, for example the description your booking form writes. The mapping you set picks it out of that text.

Job descriptiontext
Booking request from the website. Lift token: lvt_0123456789abcdef0123456789abcdef

How a payment is matched#

When a payment arrives with a token, we look its hash up, check that it belongs to this site and has not expired, and check that the visitor was shown an experiment of the site before the payment and no longer ago than the attribution window. Only then is the payment matched and credited to the variant that visitor saw. A refund finds its visitor through the original payment (the order id it points at).

Otherwise the payment is unmatched, with one of these reasons:

ReasonMeaning
no_tokenNo visitor token arrived with the payment.
token_unknownA token arrived, but we did not issue it for this site.
token_expiredThe token had already expired when the payment happened.
no_exposureThat visitor never saw an experiment on this site.
outside_windowThe visitor saw the experiment longer ago than the attribution window.
currency_mismatchThe payment is not in the revenue currency of the site. Thus, it does not count.
refund_without_originalThis refund points at a payment that this connection never recorded. Thus, it counts at site level.

The Payments page shows the share of recorded payments that matched, per connection. A low share means the token is not reaching the processor on some path: check the carrier for that checkout.

What can still be lost#

Attribution is best effort, and the product shows the loss rather than hiding it:

  • A checkout on another domain, where the token cannot be passed from your page, produces unmatched payments.
  • Ad blockers and browser storage limits can stop the snippet from fetching or keeping a token; we have not verified how Safari treats it.
  • Visitors who do not consent, or who send Do Not Track or Global Privacy Control where the site honors them, get no token by design.
  • A payment older than the attribution window, or from a visitor who was never in an experiment, is unmatched.

The token endpoint#

lift.token() calls POST /api/v1/token for you. You only need the endpoint if you build your own client, for example a native app. Send a text/plain JSON body (so no CORS preflight is needed) with the public site key and the visitor id. The request must come from an origin that is one of the site's domains.

Request bodyjson
{"k":"lift_pk_YOUR_SITE_KEY","vid":"<visitor id>"}
200 OKjson
{
  "token": "lvt_0123456789abcdef0123456789abcdef",
  "expiresAt": "2026-04-19T12:00:00.000Z"
}
StatusMeaning
200A token and the time it expires.
204No token: the visitor must not be tracked.
404Unknown site key, or an origin that is not one of the site's domains (the same answer for both).
422The body is not {"k": …, "vid": …}.
429Too many requests; wait for Retry-After seconds. A visitor can ask for 6 tokens per minute.

A token lasts as long as the attribution window of the site: 30 days unless the site's revenue settings say otherwise.