|
Note: This article is for the latest version of the tracking code. If you are using the older version, please read the following article.
To determine which tracking code you are using, please see Which version of the tracking code am I using? |
Google Analytics provides an easy way to track clicks on links that lead to file downloads. Because these links do not lead to a page on your site containing the tracking code, you'll need to tag the link itself with the _trackPageview() JavaScript if you would like to track these downloads. This piece of JavaScript assigns a pageview to any click on a link - the pageview is attributed to the filename you specify.
For example, to log every click on a particular link to www.example.com/files/map.pdf as a pageview for /downloads/map you would add the following attribute to the link's <a> tag:
<a href="http://www.example.com/files/map.pdf" onClick="javascript: pageTracker._trackPageview('/downloads/map'); ">
Important: if your pages include a call to _trackPageview, _setAllowLinker _trackTrans(), your Analytics tracking code must be placed in your HTML code above any of these calls. In these cases the tracking code can be placed anywhere between the opening <body> tag and the JavaScript call.
To verify that _trackPageviewis being called correctly, you can check your Top Content report 24-48 hours after the updated tracking code has been executed. You should be able to see the assigned pagename in your report.