Skip to content

Instantly share code, notes, and snippets.

@zufrieden
Created March 22, 2014 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zufrieden/9708339 to your computer and use it in GitHub Desktop.
Save zufrieden/9708339 to your computer and use it in GitHub Desktop.
<div class="col-xs-12">
  <div class="text-center isolated"><a href="http://register.uxlausanne.com/" class="btn btn-lg btn-primary" id="js-buy-ticket-bottom">Buy your ticket</a></div>
</div>
var buy_ticket_bottom = document.getElementById('js-buy-ticket-bottom');
addListener(buy_ticket_bottom, 'click', function() {
  ga('send', 'buy_ticket', 'button', 'click', 'above_fold');
});


/**
 * Utility to wrap the different behaviors between W3C-compliant browsers
 * and IE when adding event handlers.
 *
 * @param {Object} element Object on which to attach the event listener.
 * @param {string} type A string representing the event type to listen for
 *     (e.g. load, click, etc.).
 * @param {function()} callback The function that receives the notification.
 */
function addListener(element, type, callback) {
 if (element.addEventListener) element.addEventListener(type, callback);
 else if (element.attachEvent) element.attachEvent('on' + type, callback);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment