Created
December 19, 2014 14:58
-
-
Save erikpantzar/30ae70f9c95ea0948e6c to your computer and use it in GitHub Desktop.
Google track Terese-s sajt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
var onPageUrl = window.location.href; | |
var domain = window.location.host; | |
// all links ending with .pdf | |
$('a[href$=".pdf"]').on('click', trackPDF); | |
// all links beginning with "http" (might be https) | |
$('a[href^="http"]').on('click', function() { | |
var linkTarget = $(this).attr('href'); | |
// check if link is not local | |
if(! linkTarget.indexOf( domain ) ) { | |
trackLinks( linkTarget ); | |
} | |
}); | |
function trackPDF() { | |
_gaq.push(['_trackEvent', 'Click', 'PDF-CV', onPageUrl]); | |
} | |
function trackLinks( clickedLink ) { | |
_gaq.push(['_trackEvent', 'Click', 'ExternUrl', clickedLink]); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment