From 7f8b9909f7cd0238b801426bc99c22dbb342da2c Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 11 Feb 2016 15:59:24 +0100 Subject: [PATCH] More Google Analytics custom events - whitepaper download - all form submissions (success & error) --- .../_assets/javascripts/bigchain/analytics.js | 21 +++++++++++++++++++ _src/_assets/javascripts/bigchain/form-cla.js | 10 +++++++++ .../javascripts/bigchain/form-contact.js | 10 +++++++++ _src/_layouts/page.html | 2 +- 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/_src/_assets/javascripts/bigchain/analytics.js b/_src/_assets/javascripts/bigchain/analytics.js index 5f3fe35..acd5d2c 100644 --- a/_src/_assets/javascripts/bigchain/analytics.js +++ b/_src/_assets/javascripts/bigchain/analytics.js @@ -24,6 +24,11 @@ var GoogleAnalytics = (function(w,d,$) { $('.js-tracking-terminal').on('click', function() { ga('send', 'event', 'terminal', 'terminal_click', 'selection', true); }); + + // Whitepaper download + $('.js-tracking-whitepaper-download').on('click', function() { + ga('send', 'event', 'whitepaper', 'download', 'button', true); + }); }, @@ -105,6 +110,22 @@ var GoogleAnalytics = (function(w,d,$) { }, gaEventEarlyAccessError: function() { ga('send', 'event', 'signup', 'early_access_form', 'error'); + }, + + // contact forms + gaEventContactSuccess: function() { + ga('send', 'event', 'contact', 'contact_form', 'success'); + }, + gaEventContactError: function() { + ga('send', 'event', 'contact', 'contact_form', 'error'); + }, + + // CLA forms + gaEventClaSuccess: function() { + ga('send', 'event', 'cla', 'cla_form', 'success'); + }, + gaEventClaError: function() { + ga('send', 'event', 'cla', 'cla_form', 'error'); } }; diff --git a/_src/_assets/javascripts/bigchain/form-cla.js b/_src/_assets/javascripts/bigchain/form-cla.js index 3666077..9150c2d 100644 --- a/_src/_assets/javascripts/bigchain/form-cla.js +++ b/_src/_assets/javascripts/bigchain/form-cla.js @@ -51,12 +51,22 @@ var FormCla = (function(w, d, $) { thisForm.find('.form-group').addClass('hide'); thisForm.find('.alert-success').removeClass('hide'); thisButton.removeClass('disabled'); + + // send GA event + if (!_dntEnabled()) { + GoogleAnalytics.gaEventClaSuccess(); + } }, error: function(err) { thisForm.find('.alert-danger').removeClass('hide'); thisButton .removeClass('disabled') .attr('value', 'Send'); + + // send GA event + if (!_dntEnabled()) { + GoogleAnalytics.gaEventClaError(); + } } }); } diff --git a/_src/_assets/javascripts/bigchain/form-contact.js b/_src/_assets/javascripts/bigchain/form-contact.js index 8ea79e9..d369653 100644 --- a/_src/_assets/javascripts/bigchain/form-contact.js +++ b/_src/_assets/javascripts/bigchain/form-contact.js @@ -32,12 +32,22 @@ var FormContact = (function(w, d, $) { _config.form.find('.form-group').addClass('hide'); _config.form.find('.alert-success').removeClass('hide'); _config.formBtn.removeClass('disabled'); + + // send GA event + if (!_dntEnabled()) { + GoogleAnalytics.gaEventContactSuccess(); + } }, error: function(err) { _config.form.find('.alert-danger').removeClass('hide'); _config.formBtn .removeClass('disabled') .attr('value', 'Send'); + + // send GA event + if (!_dntEnabled()) { + GoogleAnalytics.gaEventContactError(); + } } }); } diff --git a/_src/_layouts/page.html b/_src/_layouts/page.html index 771b515..d6b437a 100644 --- a/_src/_layouts/page.html +++ b/_src/_layouts/page.html @@ -35,7 +35,7 @@ layout: base

{% for whitepaper in page.whitepaper.files %} - {{ whitepaper.button }} + {{ whitepaper.button }} {% endfor %}