ABlyft already has an integration for connecting to Google Tag Manager that can be easily activated.
The integration will push an event to the DataLayer whenever a visitor is experiencing/seeing an Experiment/Variation.

The code used is the following. Feel free to use it to create a custom integration if you do not want to use the default one or want to customize the integration.

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'ablyft-viewed-experiment',
'project_id': projectId,
  'project_name': projectName,
'experiment_id': experimentId,
'experiment_name': experimentName,
'variation_id': variationId,
'variation_name': variationName,
});

To be able to use the information in Google Analytics from the DataLayer, follow the steps listed below.

Setting up Google Tag Manager

1.  Create Data Layer Variables

Go to "Variables" and create a new one with the "Variable Type = Data Layer Variable".
As the "Data Layer Variable Name" take one of the provided object (see above - i.e. "project_id", "experiment_id", "experiment_name" and so on.). 

Repeat that step for all six variable names of the provided object.

The result should be a list looking like this:

2.  Create a Trigger for the Custom Event

In order for Google Analytics to know that a visitor at ABlyft is a test participant, a trigger must be created. 

Go to "Triggers" and create a new one with the "Trigger Type = Custom Event".
As the "Data Layer Variable Name" use "ablyft-viewed-experiment".
The Trigger should fire on "All Custom Events".

3. Connect GTM Variables to Google Analytics Event Tag 

Now it is time to create a Tag.
It is good practise to use this values (please mind that this is depending on what name you used before):

  • Category: ABlyft Project {{dlv - project_id}} 
  • Action: {{dlv - experiment_name}} (Experiment #{{dlv - experiment_id}}) 
  • Label: {{dlv - variation_name}} (Variation #{{dlv - variation_id}}) 


Example:  Custom Report in Google Analytics

You can use the Event in many ways using Google Analytics.
Here is an example how you can use it for a Custom Report. 

First, create a "Custom Report":

Add the Metrics you want to show and a the following Drilldowns:

If you like, you can add a Filter to only show ABlyft Events - or even only a specific Project. In this case we add a Filter to only show ABlyft Events:


Testing and Debugging GTM and GA 

Check if the "Google Tag Manager" Default Integration is enabled in the ABlyft Testing Platform. In addition, check if at least one Experiment is running and is being evaluated for you.

Enable the Google Tag Manager Preview Mode. Check the GTM Console in the Browser.
https://support.google.com/tagmanager/answer/6107056?hl=en  

  1. Is the Event "ablyft-viewed-experiment" firing?
  2. Does the GA Event includes the blow shown information? 

If yes, check the Google Analytics real-time view. There drill down as shown below.

There you can see how many users have been in the Experiment in the last 30 minutes.

 

Did this answer your question?