Integrate Convert Experiences with Matomo

This Article Will Help You:


Introduction

Matomo (formerly Piwik) is a free and open source Web analytics application.

With the Convert-Matomo integration, unique visitors to your experiments’ variations will be passed into Matomo using custom variables.

Read more about how you can use Matomo as an alternative to GA.

Add Tracking Codes

To set up the integration, you should install the Matomo tracking code according to Matomo’s instructions. It looks like this:


You should also install the Convert tracking code (instructions can be found here).

Custom Variables

Create a Matomo Custom Variable and note its index. If you are already using Custom Variables for the same pages you intend to pass Convert data into, you should determine which indexes are in use so that you can choose a unique index number for Convert data.

Example of the data we send to Matomo:
dimension(or index) , current Experiment Name*, current Variation*, scope: "visit" (this means the custom variable applies to the current visit)

* Depends on whether you have chosen data anonymization or not (more information on this can be found here)

Enable the Integration in Convert

To enable the integration for your experiment, go to the Experience Summary, and you should see a link to Add/Edit Integrations. Under here you will find the option to enable Matomo/Piwik integration and set the Dimension/Index you will use:

Enable the Integration Manually

Instead of using the internal integration that Convert Experiences supports, you can also add this code and activate it manually:

var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
// you can set up to 5 custom variables for each visitor
var refObject = window['convert']['data']['experiments']
for (var key in window["convert"]["currentData"]["experiments"]) {
if (!window["convert"]["currentData"]["experiments"].hasOwnProperty(key)) {
continue;
}}

var currentExperiment = window["convert"]["currentData"]["experiments"][key];
var curExperimentName = refObject[key] && refObject[key].n ? refObject[key].n : "unknown experiment name";
curExperimentName = curExperimentName.replace("Test #", "Test ");
var curVariant = currentExperiment['variation_name'] ? currentExperiment['variation_name'] : "unknown variant";
curVariant = curVariant.replace("Var #", "Variation ");


_paq.push(["setCustomVariable", 1, "Exp_Name", curExperimentName, "visit"]);
_paq.push(["setCustomVariable", 2, "Value Name", curVariant, "visit"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//con.innocraft.cloud/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();

View Convert Data in Matomo

Once you enable the integration (either through Convert interface or manually) you can view Experiment ID, Variation ID in Matomo dashboard: