The jQuery Script
[js] <pre> $("a[href$='pdf']").each(function(index) { pdfLabel = $(this).attr('href'); pdfOnClick = "_gaq.push(['_trackEvent', 'PDF', 'Download', '" + pdfLabel + "']);"; $(this).attr("onClick", pdfOnClick); });</pre> [/js]How To Find The Results In Google Analytics
When you login to Google Analytics, you can track the downloads through the event tracker with the following steps:- Click on -> Standard Reporting
- Click on -> Content
- Click on -> Events
- Click on -> Overview
- Click on the event category (i.e. ‘PDF’)
- Add the following secondary dimension: ‘Event Label’
Revisions
- June 26, 2013 @ 01:26:26 [Current Revision] by PeterLugg
- May 31, 2013 @ 01:57:24 by PeterLugg
- May 31, 2013 @ 01:55:01 by PeterLugg
Revision Differences
May 31, 2013 @ 01:55:01 | Current Revision | ||
---|---|---|---|
Content | |||
Added: Taken from here: <a href="http:// www.cre8ivespark.com/track- pdf-downloads- with-jquery" target="_blank" >http://www.cre8ivespark.com/ track-pdf-downloads- with-jquery</a> | |||
Added: In the past, it has often been an extensive process to track PDF downloads with Google Analytics. Usually, you would need to add event tracking to every PDF file on a website in order to track the number of downloads. | |||
Added: Some companies have spent quite a lot of money to organise a custom script or process in order to add tracking to each document download link on their website. | |||
Added: However that has all changed now! With the jQuery script below, you can now easily add tracking to every document of your choice. You could track Word docs, PDF docs and more. | |||
Added: <h3>The jQuery Script</h3> | |||
Added: [js] | |||
Added: <pre> $("a[href$= 'pdf']") .each(function(index) { | |||
Added: pdfLabel = $(this).attr('href'); | |||
Added: pdfOnClick = "_gaq.push( ['_trackEvent', 'PDF', 'Download', '" + pdfLabel + "']);"; | |||
Added: $(this).attr( "onClick", pdfOnClick); | |||
Added: });</pre> | |||
Added: [/js] | |||
Added: <h3>How To Find The Results In Google Analytics</h3> | |||
Added: When you login to Google Analytics, you can track the downloads through the event tracker with the following steps: | |||
Deleted: | Added: <ul> | ||
Added: <li>Click on -> <strong>Standard Reporting</strong></li> | |||
Added: <li>Click on -> <strong> Content</strong></li> | |||
Added: <li>Click on -> <strong> Events</strong></li> | |||
Added: <li>Click on -> <strong> Overview</strong></li> | |||
Added: <li>Click on the event category (i.e. ‘PDF’)</li> | |||
Added: <li>Add the following secondary dimension: ‘<strong>Event Label</strong>’</li> | |||
Added: </ul> |
Note: Spaces may be added to comparison text to allow better line wrapping.
No comments yet.