Posted By

ptlrikin on 08/07/12


Tagged

tracking


Versions (?)

Automatted Tracking to External Sites or Event Tracking


 / Published in: JavaScript
 

Add the following code to skin.js file for automated event tracking to external sites or virtual page view to PDF's.

  1. $(function(){
  2. $('a[href$=ashx]').bind('click', function (e) {
  3. e.preventDefault();
  4. _gaq.push(['_trackPageview', $(this).attr('href')]);
  5. setTimeout("window.location = '" + $(this).attr('href') + "'", 100);
  6. });
  7. $('a[href*="subdomain.domain.com"]').bind('click', function (e) {
  8. e.preventDefault();
  9. _gaq.push(['_trackEvent', 'Click to Online Application', window.location.pathname, $(this).attr('href') ]);
  10. _gaq.push(['_link', $(this).attr('href')]);
  11. setTimeout("window.location = '" + $(this).attr('href') + "'", 100);
  12. return false;
  13. });
  14. });

Report this snippet  

You need to login to post a comment.