If you use Google Universal Analytics (UA) on your website, then you can integrate Freshmarketer with UA to get accurate results on your experiments along with the web metrics collected by UA.


Why should you integrate Freshmarketer and UA?


Integrating Freshmarketer with UA allows you to


  • View web metrics tracked by UA for each variation in an experiment (running on Freshmarketer)
  • View reports in UA by filtering out only the visitors included in your Freshmarketer experiment
  • Understand how Freshmarketer experiments impact the metrics tracked by Google Analytics


Follow the 3 simple steps outlined below to successfully integrate UA with Freshmarketer


STEP 1:


Create a custom dimension in UA


It is very important to create a custom dimension in UA to ensure Freshmarketer data is accurately mapped in UA.

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


Selecting "Custom Dimensions"



Create a new ‘Custom Dimension’

Creating New "Custom Dimensions"



  1.Use one custom dimension per experiment to prevent any kind of ambiguity.


  2.Keep a track of the dimension parameter after creating the custom dimension you created (see below)


Generate GA Code



STEP 2:


Enable UA integration on the Freshmarketer tool


Once you have created the custom dimension, you have to enable the option in the tool.

Log in to app.Freshmarketer.com. Click on Setup and select Google Analytics Integration and enable UA integration in the ‘Integration’ tab.


Enabling UA Integration

Enabling UA Integration




STEP 3:


Apply the UA integration to the experiment


The next step would be to ensure the UA integration is applied to the experiment. Navigate to the summary tab of the experiment and enable UA integration.


1.Ensure the ‘Custom Dimension’ number matches with the number specified in UA
(refer to Step 1).

2.The experiment should already be running while enabling UA integration. This is to ensure no data is lost during the integration process.

3.Keep a track of the ID number.



STEP 4:


Freshmarketer's GA Code Integration


There are two types of Freshmarketert's GA code provided based on its own distinct purpose:

  1. GA integration for A/B testing
  2. GA integration for all features (Heatmaps, split URL testing and much more)


GA Integration for A/B Testing

To send Freshmarketer's A/B testing data to your GA account, copy the below code:


<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', GA_TRACKING_ID, {
'custom_map': {'dimensionIndex': 'zarget'}
});
$( document ).ready(function() {
var exps = window.zargetAPI?window.zargetAPI.getAllRunningExperiments() : [];
if(exps.length){
gtag('event', 'zargetdimension', {'zarget': 'Zarget' + exps[0]['experimentName'] +' : ' + exps[0]['appliedVariationName']});
}
});
</script>


Note: Replace GA_Tracking_ID in the code with your tracking ID & Replace Index with Custom dimension ID. Paste Freshmarketer's JS code followed by GA's tracking code and Freshmarketer's GA integration code.


Once you replace, your final code will look like below 


Example code:

<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-4428xxx2-1', {
'custom_map': {'dimension1': 'zarget'}
});
$( document ).ready(function() {
var exps = window.zargetAPI?window.zargetAPI.getAllRunningExperiments() : [];
if(exps.length){
gtag('event', 'zargetdimension', {'zarget': 'Zarget' + exps[0]['experimentName'] +' : ' + exps[0]['appliedVariationName']});
}
});
</script>


GA Integration for all features 

To send Freshmarketer's data of other features such as heatmaps and split URL testing, copy and paste the following integration code.



<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config',GA_TRACKING_ID, {
'custom_map': {'dimensionIndex': 'zarget'}
});
$( document ).ready(function() {
var exps = window.zargetAPI?window.zargetAPI.getAllRunningExperiments() : [];
if(exps.length){
$(exps).each(function(i,obj){
if(obj.type == 1 || obj.type == 4){
gtag('event', 'zargetdimension', {'zarget': 'Zarget' + obj['experimentName'] +' : ' + obj['appliedVariationName']});
}else{
gtag('event', 'zargetdimension', {'zarget': 'Zarget' + obj['experimentName']});
}
});
}
});
</script>



Note: Replace GA_Tracking_ID in the code with your tracking ID. Replace Index with custom dimension index in GA. Paste Freshmarketer's JS code followed by GA's tracking code and Freshmarketer's GA integration code.


GA Integration for a Particular Experiment


To track Freshmarketer's data of a particular experiment or campaign, copy and paste the following GA integration code:


<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config',GA_TRACKING_ID, {
'custom_map': {'dimensionIndex': 'zarget'}
});
$( document ).ready(function() {
var exps = window.zargetAPI?window.zargetAPI.getAllRunningExperiments() : [];
if(exps.length){
$(exps).each(function(i,obj){
if(obj.id === XXXX){
if(obj.type == 1 || obj.type == 4){
gtag('event', 'zargetdimension', {'zarget': 'Zarget' + obj['experimentName'] +' : ' + obj['appliedVariationName']});
}else{
gtag('event', 'zargetdimension', {'zarget': 'Zarget' + obj['experimentName']});
}
}
});
}
});
</script>



Note: Replace "XXXX" in the above code with the hash id present in the Preflight -> Experiment Info


STEP 5:   

Create Custom Report


The final step is to create a custom report in UA that allows you to view Freshmarketer experiment’s report in UA. Navigate to ‘Customization’ tab and create a ‘New Custom Report’. Add the metric groups you would like to include. In the Dimensions section, search for the custom dimension you created and add that. In the filter section, search for the Custom dimension, add that and select Regex option from the drop-down. In the text box, add the term Freshmarketer and click on ‘Save’



Creating Custom Report

Creating Custom Report


Now you have successfully integrated UA with Freshmarketer experiment. You should soon start seeing data getting populated in the custom report that you created.




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