Automatted Tracking to External Sites or Event Tracking


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

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.