Amplitude Integration

A vs B sends your experiment data to Amplitude through the Amplitude SDK that is already running on your page. There is no API key to paste in: if window.amplitude.track is there, we talk to it.

A variant is one specific version being tested: the control, or one of the challengers. Experiment views use Amplitude's own $exposure event to report which variant a visitor saw. Amplitude does not bill for this event, and it fills in the variant user property for you.

Setup

1

Go to Project Settings > Integrations

Open your project, click Settings, then open the Integrations tab.

2

Turn on Amplitude

Find the Amplitude card and switch it on.

3

Choose anything else you want sent

Under Also send, tick conversions, purchases, or recommendation events. Experiment views are always sent.

4

Save

Click Save. Your changes reach your live site within about a minute.

The Amplitude card, switched on. Experiment views use the billing-exempt $exposure event automatically.
  1. The on/off switch, top right of the card.
  2. The Also send checklist for conversions, purchases, and recommendation events.

What is sent

When a visitor is shown a variant:

TypeScript
// `amplitude` is the global the Amplitude snippet installs on the page.declare const amplitude: { track(eventName: string, properties: Record<string, unknown>): void };amplitude.track('$exposure', {  flag_key: '482',  variant: 'Variant B',  experiment_key: 'Homepage hero',  event_id: '3f9a2b1c-7d4e-4a58-9c02-5e6d1f8b3a47'});
TypeScript9 lines

flag_key, variant, and experiment_key are the three fields Amplitude Experiment reads. Anything else you switch on uses the plainer field names instead:

EventDefault nameProperties
Experiment view$exposureflag_key, variant, experiment_key, event_id
Conversionavsb_goalthe four experiment and variation fields, event_id, goal_key, plus revenue or value when you sent one
Purchaseavsb_purchasethe four experiment and variation fields, event_id, revenue, currency, transaction_id
Recommendation seenavsb_rec_impressionthe four fields, event_id, and the recommendation details
Recommendation clickedavsb_rec_clickthe four fields, event_id, and the recommendation details

Empty fields are left out rather than sent as blanks.

A conversion carries the experiment, the variation, and the goal that fired:

TypeScript
amplitude.track('avsb_goal', {  experiment_id: '482',  experiment_name: 'Homepage hero',  variation_id: '1913',  variation_name: 'Variant B',  event_id: 'b2a7e6c4-1f3a-4d8e-9b02-8c4a2e7f19d0',  goal_key: 'click:31'});
TypeScript8 lines

goal_key identifies which goal fired. For a metric you built in the metric builder, it is the metric's type and short ID joined by a colon, like click:31. For a custom event you track yourself, it is just your event's name.

Renaming events

Every name in the table can be changed on the card. Leave a box empty to keep the standard name shown inside it.

Renaming $exposure costs you two things

Amplitude does not charge for its own $exposure event, and it fills in the variant user property from it. A custom name loses both. Rename this one only if you have a reason to.

Turning it off

Switch the Amplitude card off to stop sending to Amplitude. To skip just one experiment and keep every other one on, use the Analytics forwarding switch on that experiment's review step.

Check it works

On the Integrations tab, use Send a test event. It opens your site in a new tab and sends one clearly labelled test event, avsb_test_event, to every tool you have switched on. Your project needs at least one live experiment first: the test event is sent against the first one you have.

Viewing in Amplitude

  • Experiment results: $exposure feeds Amplitude's own experiment analysis with no mapping.
  • Event Segmentation: chart $exposure and break it down by variant.
  • Funnel Analysis: start with $exposure and end with your conversion event, split by variant.
  • Retention: check whether one variation brought people back more often.
  • User Lookup: see which variation any individual was shown.
Amplitude Browser SDK v2 is required

This integration calls amplitude.track(), which is the Browser SDK v2 API. Sites still on v1 (amplitude.getInstance().logEvent()) will not receive events. Upgrade to v2, or send them yourself from the event bus.

Counts will not match exactly

Your Amplitude numbers and your A vs B results will be close but not identical. Ad blockers and consent choices affect the two systems differently. Every event carries event_id, a unique ID you can use to line individual events up.

Was this helpful?