Mobile app version of vmapp.org
Login or Join
Kevin317

: Google Analytics events not registering I am trying to track clicks on my site using the analytics.js script for tracking events. I implement the snippet and test using the "Real Time" view

@Kevin317

Posted in: #AnalyticsEvents #Google #GoogleAnalytics #UniversalAnalytics

I am trying to track clicks on my site using the analytics.js script for tracking events. I implement the snippet and test using the "Real Time" view and nothing shows up. Here is the snippet I am using:

<a href="my-file-link.pdf" onClick="ga('send', 'event', {
eventCategory: 'download', eventAction: 'click', eventLabel: 'download
overview'});" target="_blank">Link</a>


I have also tried:

<a href="my-file-link.pdf" onClick="ga('send', 'event', 'download', 'click','download overview');" target="_blank">Link</a>


Anyone know what I am doing wrong?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

1 Comments

Sorted by latest first Latest Oldest Best

 

@Sue5673885

This is the event code you want to trigger -

ga('send', 'event', 'download', 'click','download overview');


However, it could be that the tracker object (in the sample above it is ga), might have been initialized with a different variable name.

For e.g the WordPress plugin Monster Insights typically initializes the tracker object as __gaTracker.

What I would do is open up your site's source code and check the name of this tracker object.

Also for all custom tracker codes put in, it might be a good idea to check if the object exists before firing this event.

if (ga) {
ga('send', 'event', 'download', 'click','download overview');
}


Another quick method of check this script before you deploy it in your site is to run it on Developer Console of your browser and check in Google Analytics Real-time reports.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme