Wednesday, November 20, 2013

Google Analytics: Javascript actions

As it turns out, it is really easy to measure anything using google analytics on a page that already uses the tracking code.

You can use javascript to fire events that will be visible under the behaviour section of Analytics.

In our latest projet we needed to measure how many people clicked on the facebook share icon. The code we used is something like this:

 <a href="#" onclick="_gaq.push(['_trackEvent', 'Facebook', 'Click on share']); openFbPopUp('', '', 'This is', 'Lorem ipsum dolor sit amet');">Share on Facebook</a>  

The complete description can be found here: