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#
- Project → Integrations (admins).
- Switch on the tools installed on your site and, if you like, change the event name.
- 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#
| Option | Tools | What it does |
|---|---|---|
| Send only a visitor's first exposure | All | Once 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_view | GA4 (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#
| Tool | Default event | Sent as |
|---|---|---|
| Google Analytics 4 | experiment_impression | A gtag("event", …) with experiment_id, experiment_name, variant_id, variant_name and exp_variant_string (LC-<experiment>-<variation>). |
| Google Tag Manager | liftcanary_experiment | A dataLayer.push with liftcanary_experiment_id, liftcanary_experiment_name, liftcanary_variation_id, liftcanary_variation_name. |
| Segment | Experiment Viewed | An analytics.track following Segment's A/B testing spec: experiment_id, experiment_name, variation_id, variation_name. |
| Mixpanel | $experiment_started | A mixpanel.track with Experiment name and Variant name (what Mixpanel's Experiments report reads), plus the ids. |
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_nameandvariant_name(orexp_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_experimentand Data Layer Variables for theliftcanary_*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_startedon 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#
{
"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.