javascript - Google Analytics Doesn't Work on Django Site -


i set google analytics placing tracking script tag , code @ bottom of head tag in base.html template every other page extends from.

i created 2 click events when people click on pdf links.

none of events showing up. here code.

$(document).ready(function() {     $(document).on('click', '.cs-link', function() {         ga('send', 'event', {             eventcategory: 'case study',             eventaction: 'click',             eventlabel: event.target.href,             transport: 'beacon'         });     });      $(document).on('click', '.brochure-link', function() {         ga('send', 'event', {             eventcategory: 'brochure',             eventaction: 'click',             eventlabel: event.target.href,             transport: 'beacon'         });     }); }); 

i'm not sure why doesn't work. page tracking works events don't i'm not sure how tell whether or not js executing when click links.

you should add eventargument click handler function not defined in browsers

change

 $(document).on('click', '.brochure-link', function() { 

to:

 $(document).on('click', '.brochure-link', function(event) { 

alternatively change event.target.href this.href since this element event occurred on

to verify see if getting event undefined error in browser console


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -