Tracking File Downloads with Google Analytics

HTML Warning: The following requires you to modify HTML and should only be done by someone with a basic understanding of HTML. If done incorrectly this can break your links on the page.

On each link that you want to track add the following “onClick” call:

onClick="ga('send', 'event', 'download', 'click', ‘Descriptive text here');"

So it would look like this:

<a href="/RecipesForDogs.pdf" onClick="ga('send', 'event', 'download', 'click', 'Descriptive text here');">Download My Great Recipe Book for Dogs</a>

Then change the ‘Descriptive text here’ to something that describes your PDF being downloaded and you will start to see Events in your Google Analytics dashboard under the “Behavior->Events” section.

For more information please see Google’s documentation here: https://developers.google.com/analytics/devguides/collection/analyticsjs/events