1. Help Center
  2. Analyze Results

Send variations as GA events to use advanced segments (audiences)

THIS ARTICLE WILL HELP YOU:

Introduction

Convert Experiences offers a built-in Google Analytics integration. However if you want to send variations as events to GA to use advanced segments in reporting you can follow the instructions below.

Add Global Experience Javascript Code

You should open your experience in Visual Editor and find the Global Experience JS option:

 

There you should add these lines of code:

setTimeout(function(){
//Make an empty variable for experiment ID
var experimentId = xxxxxxxx;
//if Convert object exists AND an experiment with a specific experiment ID is running
if (typeof(convert) != "undefined" &&
convert.currentData.experiments.hasOwnProperty(experimentId)) {
window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments);};window.ga.l=+new Date();
}},1000);


This makes sure that the GA tracker gets all the information once it loads. Also, please make sure to fill in your own experiment ID in place of xxxxxxxx.

Add Custom Javascript Code

Now you need to add a line of event tracking code at the end of each variation (including Original). You need to change the Experiment ID number, the name of the Variation, and the Google Analytics property id (instead of UA-xxxxxxx-y):

 

setTimeout(function(){
//Make an empty variable for experiment ID
var experimentId = xxxxxxx;
//if Convert object exists AND an experiment with a specific experiment ID is running
if (typeof(convert) != "undefined" &&
convert.currentData.experiments.hasOwnProperty(experimentId)) {
//Send a non-interaction event to Google Analytics each time the experiment is displayed. That event has a Category of “Convert,” an Action that is the experiment ID, and a Label that is the variation ID of the experiment that was displayed.
window.ga = window.ga || [];
ga('create', 'UA-xxxxxxx-y', 'auto');
ga('send', 'event', 'Convert', 'exp-10023753', 'Variation1', true);
}},1000);

So what the code does is send an event to GA where the event category is Convert, action is Experiment ID and label is Variation1 (can also be Original, Variation 2 etc). 

Create GA Segments

Now you are able to create segments in Google Analytics for each of the variations. Segments are available in Admin left menu and then under Personal Tools & Assets:

 

Create separate segments for each variation, and apply them onto any report that you want.

 

So you could see something like this: