Posted By

nivasgallo on 10/26/12


Tagged

jquery click hash Analytics


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

BrockSamsom
burnandbass
appeltauer


Track clicks on #hash anchor links on Google Analytics


 / Published in: jQuery
 

This code allows Google Analytics to monitor hashtags of jQuery activated events. Very useful if you relies on modal boxes.

Este código permite ao Google Analytics monitorar hashtags e âncoras em sites com eventos ativados por jQuery. Muito útil se você utiliza caixas modais.

  1. <a href="#contact" rel="contact">Contact</a>
  2.  
  3. <script>
  4. $(document).ready(function(){
  5. //
  6. loadOnClick();
  7.  
  8. function loadOnClick() {
  9. $('a').each(function(){
  10. $(this).attr("onclick", "_gaq.push(['_trackPageview', location.pathname + location.search + jQuery(this).attr('rel')]);" );
  11. });
  12. }
  13. });
  14. </script>

Report this snippet  

You need to login to post a comment.