Goals and conversion tracking
The five goal types, how conversions are counted and attributed, and how to report custom events and revenue from your own code.
What a goal is#
A goal is one kind of conversion on a site: a click, a form submission, a page view, an event your code reports, or revenue. Goals belong to the site, not to an experiment, so the same goal can judge many experiments.
Each experiment has one primary goal and any number of secondary goals. The primary goal is the one that decides: the recommendation to ship or stop, the bandit's traffic allocation and autopilot all look at it alone. Secondary goals are measured and shown beside it so you can see what else a variant moved.
Goal types#
| Type | Defined by | Converts when |
|---|---|---|
| Click | A CSS selector | The visitor clicks a matching element or anything inside it. |
| Form submit | A CSS selector (optional) | A matching form is submitted. Without a selector, any form counts. |
| Page view | A URL rule | The visitor views a page whose URL matches the rule. |
| Custom event | An event name | Your code calls lift.track(name) with that name. |
| Revenue | An event name | Your code calls lift.revenue(amount). |
Click, form and page-view goals need no code: the snippet listens for them on every page it is installed on. Its listeners are passive — they never cancel or delay the click or the submission — and a goal that would navigate away is sent immediately, before the page unloads.
Any goal except a page view can additionally be limited to pages matching a URL rule, for example a click goal on .buy-button that only counts on /pricing. URL rules use the same match types as experiment targeting; see Targeting.
Create a click goal from the page
Custom events#
Report anything the snippet cannot see by itself — a completed signup, a plan chosen in a modal, a video watched to the end — with lift.track():
// Converts every custom goal whose event name is "signup_completed".
lift.track('signup_completed');
// Only the name and a numeric "value" are used. Any other property is ignored:
// it is not sent to Avenue Lift and not forwarded to your analytics integrations.
lift.track('plan_selected', { value: 49 });- The name must match the goal's event name exactly. Names longer than 128 characters are dropped.
- Only
value, when it is a finite number, is sent with the event. Every other property is ignored: it never leaves the browser and is not forwarded to your analytics integrations, which receive experiment exposures only. That keeps personal data out of Avenue Lift by construction; to segment by a property, send the event to your analytics tool yourself. - Calls are safe at any time: wrong arguments are ignored, and nothing throws.
Calling before the script has loaded
With the tag installed synchronously in the head, window.lift exists by the time your own scripts run. If the snippet is loaded later (through a tag manager, for example), define the global as an array first. Calls pushed to it are queued and replayed in order once the snippet starts:
<script>
window.lift = window.lift || [];
lift.push(['track', 'signup_completed']);
lift.push(['revenue', 129.0]);
lift.push(['onReady', function (api) { console.log(api.version); }]);
</script>Revenue#
Call lift.revenue() where an order is confirmed, with the order value as a number in the site's currency:
// On the order confirmation page, in the site's currency.
lift.revenue(129.0);- The amount must be a positive, finite number. Zero, negative values and strings are ignored.
- The call reports to every revenue goal of the site (within the goal's URL scope, when it has one). A revenue goal still has an event name, which identifies it in the dashboard and the API.
- Call it once per order. Each call adds to the visitor's total, so calling it again on a reload of the confirmation page counts the order twice — guard it with your own “already reported” flag.
- Revenue goals are judged on revenue per visitor, not on conversion rate: a variant that sells fewer but larger orders can win.
Reporting from your server
When the conversion happens where no browser snippet runs — a payment webhook, a hosted checkout — report it with the server SDK. You need the visitor id (the snippet's first-party cookie) and the assignment the visitor had:
// Report a conversion from your server (for example after a payment succeeds).
await lift.track(
{ visitorId, url: 'https://www.example.com/checkout/complete' },
{
type: 'conversion',
experimentId: assignment.experimentId,
variantId: assignment.variantId,
goalId: 'GOAL_ID_FROM_THE_DASHBOARD',
value: 129.0, // revenue goals only
},
);How conversions are counted#
- The unit is the visitor
- A visitor who converts five times on a goal is one converting visitor. Conversion rate is converting visitors divided by exposed visitors. The number of conversions and the summed value are kept as well.
- Exposure comes first
- A conversion only counts for an experiment if the visitor was exposed to it — saw a page the experiment runs on, after being assigned. Conversions by visitors outside the experiment are not part of its results.
- Attributed to the first variant seen
- The conversion is credited to the variant recorded at the visitor's first exposure, whatever a later event claims.
- Any page of the site
- The conversion does not have to happen on the tested page. A thank-you page view converts an experiment that ran on the home page, because the snippet remembers the visitor's assignments.
- While running or paused
- Conversions keep being attributed while an experiment is paused, so visitors who were exposed before the pause can still complete their purchase.
- Winner rollouts are not measured
- Once a winner is promoted and served to everyone there is nothing to compare, so no exposures are recorded for it.
Traffic that should not be measured is dropped on arrival: known bots and automated browsers, requests from hosts that are not among the site's domains, and visitors who opted out (see Consent and privacy). Preview and editor sessions record nothing at all.