Skip to content

Instantly share code, notes, and snippets.

View andrewheins's full-sized avatar

Andrew Heins andrewheins

View GitHub Profile
@andrewheins
andrewheins / obxdesignworks
Created June 25, 2012 18:18 — forked from williamdodson/obxdesignworks
Track PDF files in Google Analytics with jQuery
/**
* Place this code after your Google Analytics scripts
*/
$(function() {
/* any links to PDFs are tracked with GA */
$('a[href$="pdf"]').click(function(e){
/* grab only the file name without the full path */
var fullpath = $(this).attr('href');
var filename = fullpath.substr(fullpath.lastIndexOf("/")+1, fullpath.length);
_gaq.push(['_trackPageview', '/'+filename]);