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 event
argument 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
Post a Comment