# etracker

URL: https://docs.ablyft.com/developers/integrations/etracker/

> Send the experiments and variations a visitor saw to etracker as a user-defined event and compare them with segments.



With a custom integration, ABlyft sends a user-defined event to etracker whenever a visitor sees an experiment. In
etracker you compare the variations with one segment per variation.

## What you need

* The etracker tracking code is installed on your pages.
* Events are counted towards your etracker hit quota. Check your contract if you expect a lot of traffic.

## Create the integration in ABlyft

1. Open **Project → Integrations → Custom Integrations** and create a new integration, for example `etracker`.
2. Choose the trigger **Experiment viewed** (default) or **User bucketed**.
3. Paste the code below and save. The snippet is republished automatically.

Details about triggers, timing and available data: [Custom Integrations](https://docs.ablyft.com/developers/integrations/custom-integrations/).

## Integration code

```js
var _etrackerOnReady = typeof _etrackerOnReady === 'undefined' ? [] : _etrackerOnReady;
_etrackerOnReady.push(function () {
  _etracker.sendEvent(new et_UserDefinedEvent(
    experimentName,
    'ABlyft',
    experimentId + ':' + variationId,
    variationName
  ));
});
```

The four parameters of `et_UserDefinedEvent` are object, category, action and type. Here the object is the experiment
name, the category is `ABlyft`, the action is `<experimentId>:<variationId>` and the type is the variation name.

The constants `experimentId`, `experimentName`, `variationId` and `variationName` are provided by ABlyft. They are also
available as `experiment.data.id`, `experiment.data.name`, `variation.data.id` and `variation.data.name`.

> **Check before use:** etracker expects values to be URL-encoded. If your experiment or variation names contain special characters, wrap
> them in `encodeURIComponent()`. Whether this is needed for your account, and how the encoded names are shown in
> reports, is not covered by the documentation. Test it first.

## Where you see the data in etracker

The four values become the dimensions Object, Category, Action and Type of the event. Use them as follows:

1. In etracker, open **Web Analytics → Custom Reports** and create a report for the events.
2. Create one segment per variation, for example with the condition that the action equals or contains
   `<experimentId>:<variationId>`.
3. Add metrics such as visitors and conversion rate and apply the segments side by side.

etracker does not calculate the statistical significance of the experiment for you. Use ABlyft **Results** for that.

## Check the setup

1. Open the experiment with **Run in preview mode** and enable **Run in preview mode** in the integration.
2. In the browser developer tools, look at the network requests to etracker for the event.
3. Check in etracker that the event arrives with the category `ABlyft`.

> **Notes:** Custom integrations do not run when a visitor opted out or sends Do Not Track. etracker may need its own consent
> setting. Which user-defined events must be set up in etracker before they are reported depends on your account, so
> set up the tracking in etracker first. The exact menu names and report paths can differ between etracker versions.

[etracker documentation](https://help.etracker.com/en/article/event-tracking/)

