3/30/12

Adding Google Analytics Java Script Event Tracking

To add Google Analytic tracking events for any java script event use this code:


_gaq.push(['_trackPageview', '/pagename/item-to-track']);


This assumes you have included your analytics code:



var _gaq=[["_setAccount","UA-XXXXX-X"],["_trackPageview"]];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
s.parentNode.insertBefore(g,s)}(document,"script"));


So for example: Click Me

11 comments:

  1. Analytics is a great tool to check where the traffic on your website is coming from. You can even go into specifics and tell what city they are from, what browser they are using, how long they are staying on your website.google dashboard

    ReplyDelete