# Matomo

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

> Send the experiments and variations a visitor was assigned to Matomo Tag Manager and compare variations in Matomo.



ABlyft has a built-in Matomo integration. Once it is active, ABlyft adds an event with the experiment and variation to
the Matomo Tag Manager data layer. A tag in your Matomo Tag Manager container turns it into a Matomo event, so you can
compare the variations next to your other reports.

## What you need

* The Matomo Tag Manager container is installed on the pages where your experiments run.
* A trigger and a tag in the container that react to the ABlyft event (see [Where you see the data in Matomo](#where-you-see-the-data-in-matomo)).

## Activate the integration

1. Open **Project → Integrations**.
2. Find the **Matomo** card and switch the toggle from **Not active** to **Activated**.
3. Confirm. ABlyft republishes the project.

There are no settings for this integration.

## What you get

ABlyft adds an event to the Matomo Tag Manager data layer with these fields:

| Field           | Value                  |
| --------------- | ---------------------- |
| `event`         | `custom_event`         |
| `eventCategory` | `ab_test`              |
| `eventAction`   | Name of the experiment |
| `eventName`     | Name of the variation  |

Names only, no IDs. The event is added on **User bucketed**: once, when the visitor is assigned to a variation for the
first time in this browser. It is not repeated on later page views. The event does not send anything to Matomo on its
own. A tag in your container has to react to it.

If the tool loads slightly later, ABlyft tries again for a short time.

Need a different format? [Build a custom integration](https://docs.ablyft.com/developers/integrations/custom-integrations/).

## Where you see the data in Matomo

The event only reaches your reports if the container reacts to it. In Matomo Tag Manager:

1. Create a trigger of type **Custom Event** with the event name `custom_event`.
2. Create three variables of type **Data Layer** with the names `eventCategory`, `eventAction` and `eventName`.
3. Create a Matomo Analytics tag that tracks an **Event** and use the three variables for category, action and name.
   Use the trigger from step 1.
4. Publish the container.

Afterwards the events appear in the Matomo reports with the category `ab_test`, the experiment name as action and the
variation name as name. To compare variations, use these values in Matomo segments, for example one segment per
variation, and apply the segments side by side. Matomo does not calculate
statistical significance. Use ABlyft **Results** for that.

## Check the setup

1. Open your site with an experiment you are bucketed into. Use a new private window, because the event is added only for
   a first assignment in a browser.
2. Use the Matomo Tag Manager preview mode to check that your trigger fires, and then check the event in Matomo.

> **Notes:** The integration does not run when tracking is disabled for the visitor (opt-out or Do Not Track). Matomo may need its
> own consent category in your consent tool.

[Matomo documentation](https://developer.matomo.org/guides/tagmanager/datalayer)

