Created
July 18, 2013 22:57
-
-
Save sivagao/6033822 to your computer and use it in GitHub Desktop.
using google analytics to track|log your page action|event.
http://think2loud.com/105-use-jquery-with-google-analytics-to-track-clicks-on-outgoing-links-from-your-site/
todo: understand what ga do in default..
This file contains hidden or 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
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); | |
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js'type='text/javascript'%3E%3C/script%3E")); | |
var pageTracker = _gat._getTracker("YOUR ACCOUNT NUMBER HERE"); pageTracker._trackPageview(); | |
$(document).ready(function(){ | |
$('a[data*="track"]').click(function(){ | |
pageTracker._trackPageview('click_link/'+$(this).attr('href')); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment