Set up file upload tracking for Google Analytics, the new Universal Analytics tracking

I am a bit confused. I keep finding many examples (like this and this ) that explain how to track file uploads with Google Analytics. The problem is that most of the articles are pretty old and Google is now using the new tracking code "Universal Analytics".

But here's my dilemma. I don't want to mess up my download links by installing code that may not work on some web browsers ( see comments for this page.)

So I'm curious if there are official instructions (from Google for the year 2014 ) on how to set up file upload tracking, where is there an example of JavaScript they recommend?

+3


source to share


1 answer


Download tracking is simple and very similar to all other onclick events. The general download tracking code might look like this:

<a href='/some/file.pdf' onclick="ga('send', 'event', 'download', 'click', $(this).attr('href');")>Click to download</a>

      

This sends a download event to GA, characterized by the category "download", a "click" action, and a label using your link's href attribute.



Here's a site (from 2014) you can check out: http://netnix.org/2014/04/27/tracking-downloads-with-google-analytics/ .

Hope it helps.

+3


source







All Articles