LiftCanary

Guides

Integrations

Send experiment exposures to Google Analytics 4, Tag Manager, Segment and Mixpanel.

Send experiment data to the analytics tools you already use. When a visitor enters an experiment, the website snippet sends an event saying which experiment and which variation to Google Analytics 4, Google Tag Manager, Segment or Mixpanel. You can then compare variations there on any metric you track in that tool, next to LiftCanary's own results.

Turn one on#

  1. Project → Integrations (admins).
  2. Switch on the tools installed on your site and, if you like, change the event name.
  3. Save. Every environment's datafile picks it up within seconds; no code changes.

The snippet never loads a tool: it reports to the ones on the page. A tool that loads after the snippet is waited for, for up to 10 seconds. By default a visitor is reported on every page view where they see the experiment (once per page), which ties the experiment to each of their sessions in the tool. Previews and the visual editor are never reported.

Options#

OptionToolsWhat it does
Send only a visitor's first exposureAllOnce per visitor, experiment and variation, remembered in their browser (localStorage), instead of on every page view. Fewer events in the tool; session-based reports then only see the first session.
Wait for GA4's page_viewGA4 (on by default)Sends only after the page has set GA4 up (gtag("config", …), which sends page_view), so the event lands in the visitor's session and isn't lost before GA4 is ready. Turn it off only if events don't arrive because your site sets GA4 up differently (for example only through Tag Manager: use the GTM integration there).

What each tool gets#

ToolDefault eventSent as
Google Analytics 4experiment_impressionA gtag("event", …) with experiment_id, experiment_name, variant_id, variant_name and exp_variant_string (LC-<experiment>-<variation>).
Google Tag Managerliftcanary_experimentA dataLayer.push with liftcanary_experiment_id, liftcanary_experiment_name, liftcanary_variation_id, liftcanary_variation_name.
SegmentExperiment ViewedAn analytics.track following Segment's A/B testing spec: experiment_id, experiment_name, variation_id, variation_name.
Mixpanel$experiment_startedA mixpanel.track with Experiment name and Variant name (what Mixpanel's Experiments report reads), plus the ids.
What GA4 receives
gtag("event", "experiment_impression", {
  experiment_id: "checkout_redesign",
  experiment_name: "Checkout redesign",
  variant_id: "one_page",
  variant_name: "One-page checkout",
  exp_variant_string: "LC-checkout_redesign-one_page",
});

In each tool#

  • GA4: register experiment_name and variant_name (or exp_variant_string) as event-scoped custom dimensions, then build a segment or comparison per variation in Explorations.
  • Google Tag Manager: create a Custom Event trigger for liftcanary_experiment and Data Layer Variables for the liftcanary_* keys, then send them to any tag (Hotjar, Meta, Floodlight…).
  • Segment: the event reaches every destination you've connected; Amplitude, Braze and others understand Segment's Experiment Viewed.
  • Mixpanel: the Experiments report finds $experiment_started on its own.

Experiment names#

By default the tools get keys (checkout_redesign, one_page). Switch on Send experiment and variation names to send the names you see in LiftCanary. Names are then part of the datafile every visitor downloads, so anyone can read them: leave it off if a name reveals plans you want to keep private. Renaming an experiment updates the name within seconds.

API#

PUT /v1/projects/web/integrations
{
  "ga4": { "enabled": true, "eventName": "", "waitForPageView": true },
  "segment": { "enabled": true, "eventName": "AB Test Viewed", "firstOnly": true },
  "sendNames": true
}

Admins only. Tools and options you leave out keep their setting; an empty eventName means the default. waitForPageView is for ga4 only. GET returns every tool with enabled, eventName, defaultEventName, firstOnly (and waitForPageView for GA4). In the datafile the switched-on tools appear under integrations.