Skip to content

Instantly share code, notes, and snippets.

@tosbourn
Created May 12, 2016 15:02
Show Gist options
  • Save tosbourn/a5f42242a1f9205426bae607fd5bcfce to your computer and use it in GitHub Desktop.
Save tosbourn/a5f42242a1f9205426bae607fd5bcfce to your computer and use it in GitHub Desktop.
Tito.on('registration:started', function(data){
for(var i=0; i<data.line_items.length; i++) {
var line_item = data.line_items[i];
ga('ec:addProduct', {
'id': line_item.release_slug,
'name': line_item.title,
'price': line_item.price,
'quantity': line_item.quantity
});
ga('ec:setAction', 'add');
}
ga('send', 'event', 'tito', 'registration:started', 'Started registering');
})
Tito.on('registration:filling', function(data){
ga('ec:setAction','checkout', {
'step': 1,
'name': data.name,
'email': data.email
});
ga('send', 'event', 'tito', 'registration:filling', 'Started filling in registration details');
fbq('track', 'InitiateCheckout', {value: data.total, currency: data.currency});
})
Tito.on('registration:finished', function(data){
ga('set', '&cu', data.currency);
var eventTitle = ('event' in data && 'title' in data.event) ? data.event.title : 'Ticket';
var eventBrand = ('event' in data && 'account_name' in data.event) ? data.event.account_name : 'Tito';
for(var i=0; i<data.line_items.length; i++) {
var line_item = data.line_items[i];
ga('ec:addProduct', {
'id': line_item.release_slug,
'name': line_item.title,
'price': line_item.price,
'quantity': line_item.quantity,
'category': eventTitle,
'brand': eventBrand
});
}
ga('ec:setAction', 'purchase', {
'id': data.slug,
'revenue': data.total,
'tax': data.receipt.tax,
'coupon': data.discount_code
});
ga('send', 'event', 'tito', 'registration:finished', 'Registration finished');
})
Tito.on('registration:complete', function(data){
ga('set', '&cu', data.currency);
var eventTitle = ('event' in data && 'title' in data.event) ? data.event.title : 'Ticket';
var eventBrand = ('event' in data && 'account_name' in data.event) ? data.event.account_name : 'Tito';
for(var i=0; i<data.line_items.length; i++) {
var line_item = data.line_items[i];
ga('ec:addProduct', {
'id': line_item.release_slug,
'name': line_item.title,
'price': line_item.price,
'quantity': line_item.quantity,
'category': eventTitle,
'brand': eventBrand
});
}
ga('ec:setAction', 'purchase', {
'id': data.slug,
'revenue': data.total,
'tax': data.receipt.tax,
'coupon': data.discount_code
});
ga('send', 'event', 'tito', 'registration:complete', 'Registration complete', parseInt(data.total, 10));
fbq('track', 'Purchase', {value: data.total, currency: data.currency});
window.google_trackConversion({
google_conversion_id: 1014967498,
google_conversion_language: "en",
google_conversion_format: "3",
google_conversion_color: "ffffff",
google_conversion_label: "ByggCMD8_VoQytn84wM",
google_remarketing_only: false
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment