Summary
Convert provides different options to send data to GA. One of them is to send data as a string into GA (pipe) for the user to manipulate it and insert it into GA as you please.
Extracting the Data from your page and sending it to GA
The data will be sent in the following format as a string in the chose dimension to GA, depending of the number of experiments the user is bucketed on:
e:experimentid1=v:correspondingvariationid,e:experimentid2=v:correspondingvariationid,e:experimentid3=v:correspondingvariationid
First, you will need to place some code in the Convert app in Project Settings > Global Project Javascript.
To send the data to Google Analytics insert this:
/* Push Convert data to GA as Pipe */
setTimeout(function(){
if (ga){
var dimension = 'dimension1'; // Set this to the dimension you want to send the data to
var exp = convert.currentData.experiments;
var number_of_experiments = Object.keys(exp).length;
var loop_counter = 0;
var reporting_string = '';
for (var expID in exp){
reporting_string = reporting_string + 'e:' + expID + '=' + 'v:' + exp[expID].variation_id;
if (loop_counter < (number_of_experiments - 1)) {
reporting_string = reporting_string + '|';
}
loop_counter++
}
var trackername = window.ga.getAll()[0].get("name");
ga(trackername+'.send', 'pageview' ,{dimension: reporting_string})
}
},1000);
/* End of code*/
To send the data through GTM. This article does not cover how to move the information from GTM to GA. However, still provides value on how to send the data via GTM via this format.
/* Push Convert data to GTM as Pipe */
setTimeout(function(){
if (window.dataLayer){
var dimension = 'dimension1' // Set this to the dimension you want to send the data to
var exp = convert.currentData.experiments;
var number_of_experiments = Object.keys(exp).length;
var loop_counter = 0;
var reporting_string = '';
for (var expID in exp){
reporting_string = reporting_string + 'e:' + expID + '=' + 'v:' + exp[expID].variation_id;
if (loop_counter < (number_of_experiments - 1)) {
reporting_string = reporting_string + '|';
}
loop_counter++
}
window.dataLayer.push({'ConvertExperiments':reporting_string,'dimension':dimension});
}
},1000);
/* End of code*/
From here, you can choose how to insert the data into GA.
If using the GA option you will need to create the Custom Dimension in GA and address the index in the code as commented.
Name the dimension. Select Session as the Scope, and Save it.
Lookup the dimension index, and use it in your code for setting it as instructed in the GA code comments.
In this, we would use 'dimension18' in the code.
Now, you will be able to use the data in GA and GTM as you wish.
Comments