Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Integrating Zarget with Google Analytics Using Google Tag Manager

Integrating Google Analytics to the Zarget data would provide many valuable insights. By finding visitors bucketed to the Zarget experiment, one can get many useful metrics from GA as well.

With GTM, you can get the same wealth of metrics from your GA at ease.

On a side note, to integrate Zarget or Google Analytics through Google Tag Manager, you must fire the GA code using Tag Manager and at least one Zarget A/B testing experiment should be running.

This article discusses about integrating Zarget with GA through GTM. Walk through this guide to know more on it.

Gaining Zarget Data

Click Add a new tag and select Custom HTML Tag. This tag will collect the relevant data from the Zarget javascript object.

Zarget GTM Integration

Zarget GTM Integration

Fire the below Zarget snippet to all the pages:

<script> 
function zargetGAInteg(){  
  var runningABExps = window.zargetAPI.getAllRunningExperiments('ab');
  if(runningABExps.length){
    var currentAbExp = runningABExps[0];
   	dataLayer.push({
    'zargetExpId': currentAbExp.id,
    'zargetVarName': currentAbExp.appliedVariationName,
    'event':'zargetData'
  }); 
  }
}  
  if(window.zargetAPI && window.zargetAPI.expLoaded) {
     zargetGAInteg();
  }else {
    if(document.body.addEventListener){
      document.body.addEventListener("experimentLoaded", zargetGAInteg, false);
    }else{
      document.body.attachEvent("experimentLoaded", zargetGAInteg);
	}
  }
</script> 

Your code should look like this:

Code Installation

Code Installation

Add the above code under Configure Tag section and click All Pages button under Fire on section. On clicking the Create tag button, the tag will be created.

The variables zargetExpId and zargetVarName will fetch the data from the running Zarget experiment. Hence, the next step is to create data layer variables for the specified variables.

Feeding The A/B Test to Google Universal Analytics

To feed the data of a running A/B test experiment, it involves three steps:

  • Create two variables to transfer the data layer information to the tag
  • A trigger to fire when the Zarget data is added to the data layer variables.
  • A tag to send the collected data to the Google Analytics.

STEP 1 Creation of Data Variables in Gtm

Now, the data variables need to be added to the GTM. Create two data layer variables in GTM to transfer the information to the tag.

Select Variables from the left side panel.

"Variables" in GTM Panel

"Variables" in GTM Panel

A new variable creation box appears. Give an appropriate title and select Data Layer Variable.

Variable Creation Box

Variable Creation Box

Add zargetExpId in the Configure Variable section and Click on Select Variable button.

NOTE:

Similarly, create another data layer variable for zargetVarName.

STEP 2 Creation of Trigger in GTM

Select Triggers from the left side panel of your page.

"Triggers" in GTM Panel

"Triggers" in GTM Panel

In the trigger creation page, select Custom Event. Add the event name as zargetData.

Trigger Creation Page

Trigger Creation Page

Click Create Trigger button. Now, the data collected will be transferred to GA upon firing this custom event or trigger.

STEP 3 Creation of Tag For GA in GTM

This step sends all the information collected from the running A/B test experiment to GA.

Choose Google Analytics and Universal Analytics in tag type section.

Add the Tracking ID that is found in your GA admin Panel under Property settings.

Add the event name that you created previously in Category.

Add the correct dimension value and index from the drop down menu.

Creating Tag For GA in GTM

Creating Tag For GA in GTM

NOTE:
It is very important to create a custom dimension in UA to ensure Zarget data is accurately mapped in UA.
In case the custom dimension is not found, follow the below steps:

  • Log in to your UA account. Navigate to the ‘Admin’ tab and select "Custom Dimensions"
Custom Definitions in UA

Custom Definitions in UA

Create a new ‘Custom Dimension’

Creating a New Custom Dimensions

Creating a New Custom Dimensions

Upon adding all the values, it should appear as below:

Zarget GA and GTM Integrations

Zarget GA and GTM Integrations

Now that you have successfully integrated Zarget with GA through GTM. You can view metrics for the A/B test data in GA seamlessly.


Technical Support
Don't see what you're looking for? Just drop us a mail

Integrating Zarget with Google Analytics Using Google Tag Manager