Push Convert data to GA with Event Tracking

Push Convert data to GA using Custom Dimensions or Custom Variables

If you want to push Convert data to legacy Google Analytics (Classic Analytics ga.js) using Custom Variables, you can do it like this:

Tip

If you want to push Convert data to Google Analytics (Universal Analytics analytics.js or Global Site Tag gtag.js) using Custom Dimensions, you can do it like this:

Tip

Push Convert data to GA using GTM Data layer

If you want to push Convert data to Google Analytics (Universal Analytics analytics.js or Global Site Tag gtag.js) using the Google Tag Manager Data layer you can do it like this:

Tip

If you want to push Convert data to Google Analytics 4 using the Google Tag Manager Data layer you can do it like this:

Tip

Push Convert data to GA using Event Tracking

However, there might be a case where you do not want to touch your GA Custom Dimensions or Variables or the GTM Data Layer. In that scenario, you can use GA Event Tracking. Depending on the version of GA that you use, find some useful documentation here on the commands that you should use:

  1. Event Tracking in GA Legacy (ga.js): https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
  2. Event Tracking in Universal Analytics (analytics.js): https://developers.google.com/analytics/devguides/collection/analyticsjs/events
  3. Event Tracking in GTAG (gtag.js): https://developers.google.com/analytics/devguides/collection/gtagjs/events
  4. Event Tracking in GA4: https://developers.google.com/analytics/devguides/collection/ga4/events 

Then you can view Convert data inside GA through Events reports.

Below we describe how this is possible in Universal Analytics (universal.js), Global Site Tag (gtag.js) and in Google Analytics 4.

Event Tracking in Universal Analytics (universal.js)

Add Global Project Javascript

Go to your Convert Project settings and under Global Project Javascript add the code:

blobid0.png

/* Push Convert data to GA (Universal Analytics) with Event Tracking */
setTimeout(function(){
if (ga){
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('create', trackername, 'auto');
ga(trackername+'.send', 'event' ,'Convert', reporting_string, true);
}
},1000);
/* End of code*/
  • If you use ga.js, then you have to use _gaq.push.
  • If you use analytics.js, you need to use ga('send'...) like in the code example above.
  • If you use gtag.js you should use the syntax with gtag('event'...and add Action, Category, Label, Value)
  • if you use GA4 you should use the new syntax with gtag('event'... and adding up to 4 parameters). 

View Convert Data in GA

Once the experiment runs, you can go to Real Time> Events and see the Convert data:

mceclip1.png

Event Tracking in Global Site Tag (gtag.js)

Add Global Project Javascript

Go to your Convert Project settings and under Global Project Javascript add the code:

blobid0.png

/* Push Convert data to GA (Global Site Tag) with Event Tracking */
setTimeout(function(){
if (gtag){
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++

gtag('event', 'Convert', {'event_category':reporting_string, 'event_label':'true'});
}
},1000);
/* End of code*/
  • If you use ga.js, then you have to use _gaq.push.
  • if you use GA4 you should use the new syntax with gtag('event'... and adding up to 4 parameters). 

View Convert Data in GA

Once the experiment runs, you can go to Real Time> Events and see the Convert data:

mceclip2.png

Event Tracking in Google Analytics 4 (GA4)

Add Global Project Javascript

Go to your Convert Project settings and under Global Project Javascript add the code:

blobid0.png

/* Push Convert data to GA4 with Event Tracking */
setTimeout(function(){
if (gtag){
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++

gtag('event', 'Convert', reporting_string);
}
},1000);
/* End of code*/

View Convert Data in GA

Once the experiment runs, you can go to Real Time> Events and see the Convert data.

Need assistance? Start a conversation with our Support Team.
CONVERT MORE

Reliably Convert More Site Visitors, Even If Everything Else is Changing in Your Business.

START 15-DAY FREE TRIAL
✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features

Comments