Track clicks with Google Analytics


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $(document).ready(function(){
  2. var localserver = "www.prodevtips.com";
  3. $("a").not(".kLink").not("a[href^='http://"+localserver+"']").click(function(){
  4. $(this).attr("target", "blank");
  5. var url = $(this).attr("href").replace(/^http\:\/\/(www\.)*/i, "");
  6. pageTracker._trackPageview('/external/'+url);
  7. });
  8. });

URL: http://www.prodevtips.com/2008/08/19/tracking-clicks-with-jquery-and-google-analytics/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.