Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#multipletrackers
ga('create', 'UA-54906935-2', 'auto', {'name': 'lifefuelsTracker'});
ga('require', 'ec');
ga('ec:setAction', 'purchase', {
'id': 'SET_TRANS_ID_HERE', // (Required) Transaction id (string).
'revenue': 'SET_TOTAL_HERE', // Revenue (currency).
'coupon': 'SET_COUPON_HERE' // Transaction coupon (string).
});
ga('lifefuelsTracker.send', 'event', 'preorders', 'completed purchase');
// Adding new tracker to send lifefuels specific events.
//https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#multipletrackers
ga('create', 'UA-54906935-2', 'auto', {'name': 'lifefuelsTracker'});
$('.tilt_modal input, .tilt_modal select')
.on('blur', function(e) {
'use strict';
var obj = e.currentTarget;
var value = obj.value;
if (obj.name.match(/^(card_number|security_code)$/) && value) {
value = '(omitted)';
}
ga('lifefuelsTracker.send', 'event', 'preorders', 'form-input', obj.name + ': ' + value);
});
$('.tilt_modal button')
.click(function(e) {
'use strict';
var obj = e.currentTarget;
// run in next tick so that the form can be validated, 0 moves this function to the end of the execution loop.
setTimeout(function() {
var invalidFields = $('input.error, select.error', obj.form).map(function(idx, elem) { return elem.name; }).get();
if (invalidFields.length > 0) {
ga('lifefuelsTracker.send', 'event', 'preorders', 'form-invalid', invalidFields.join(', '));
}
else {
ga('lifefuelsTracker.send', 'event', 'preorders', 'preorder-submit');
}
}, 0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.