Fri Jan 27 2017
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
function fireEAndEEvent(eventname, detail){
    if (window.CustomEvent) {
      var event = new CustomEvent(eventname, {detail: detail});
    }
    else if(typeof document.createEvent == 'function') {
      var event = document.createEvent('CustomEvent');
      event.initCustomEvent(eventname, true, true, detail);
    }
    else {
      'console' in this && !!console.warn && console.warn('Custom Event unavailable for analytics.'); 
    }
    document.dispatchEvent(event);
}

//We'll use 'eande_emailsignup' as the name for the event. Send vertical for the signup as the 'vertical' property of the second argument (one of ['business','k12','publicsector','highered']) - it will default to 'business' (event42 in analytics). 
//When someone signs up, call the function like so: fireEAndEEvent('eande_emailsignup', {vertical:'k12'})