LiftCanary

Guides

From landing page to app

Count an anonymous visitor and the account they sign up for as one person, across domains and your server.

A common test starts on the landing page, where nobody is signed in, and is decided by what people do inside the app after they sign up: generate their first output, start a trial, pay. On the landing page a visitor has an anonymous id; in the app they have your user id. LiftCanary links the two at sign-in, so results count one person: the variation they saw as a visitor, and everything they did as a user.

What goes wrong without it#

Results compare people by id. Without a link, the anonymous visitor and the signed-in user are two people:

SituationResult without a link
The app doesn't decide the flag againThe exposure belongs to the anonymous id and the conversion to the user id: the conversion is lost and the rate looks close to zero.
The app decides the flag againEveryone who signed up counts twice (once without converting, once converting): the rate is diluted and noisier.
Landing and app on different subdomainsEach subdomain has its own storage, so the app sees a different anonymous id and possibly another variation.
The conversion is recorded by your serverThe server never knew the visitor's anonymous id.

Set it up#

  1. Share the anonymous id across your domains

    The snippet keeps the anonymous id in a first-party cookie, liftcanary_anon, as well as in localStorage. When the landing page and the app live on different subdomains (example.com and app.example.com), set the cookie on the parent domain on both:

    HTML
    <script src="https://example.com/_sk/sdk/v1/liftcanary.js" data-sdk-key="pk_…" data-cookie-domain=".example.com"></script>

    On a single domain you don't need it.

  2. Link at sign-in

    Call identify when the visitor signs up or signs in (or render the app with data-user-id). With bucketing: "anonymous" they also keep the variation they saw on the landing page:

    JavaScript
    // After sign-up / sign-in, in the browser
    liftcanary.identify(user.id, { plan: user.plan }, { bucketing: "anonymous" });
    // or on every app page: <script … data-user-id="u_8812" data-bucketing="anonymous">

    The snippet sends one link (an identify event) per browser and user, not one per page. If your server handles sign-in, link there instead, reading the cookie:

    from liftcanary import ANONYMOUS_ID_COOKIE
    
    anon = request.COOKIES.get(ANONYMOUS_ID_COOKIE)  # Django; Flask: request.cookies
    user = liftcanary.create_user(str(request.user.id), anonymous_id=anon, bucketing_id=anon)

    anonymousId links the ids (sent once per process, however many requests). bucketingId is optional: pass the same value only if the server should decide the flag the way the landing page did.

  3. Track the outcome under the user

    Track as usual, from the app or from your server; the user id is enough once linked:

    Python
    user.track("output_generated")
  4. Read the result

    Create the experiment on the landing page flag with output generated as the primary goal. The rate is: people who saw a variation on the landing page, and later generated an output under any of their ids, divided by everyone who saw it. Visitors who never signed up stay in the denominator, which is what you want to compare. For the steps in between, add a funnel such as landing → sign-up → first output.

How people are counted#

  • Every id is resolved to a person first: an anonymous id that was linked belongs to its user; anything else is its own person.
  • An anonymous id belongs to the first user it was linked to. If someone else signs in on the same computer later, they aren't merged.
  • A user who signed in from several devices collects all their anonymous ids.
  • A person exposed to two different variations (for example a test that started before login with user bucketing) is left out, as before.
  • reset() at logout also starts a new anonymous id, so whoever uses the browser next isn't linked to the user who left.
  • Links apply to past and future data: results computed after a sign-in include that visitor's earlier landing-page exposure.