Support » Requests and Feedback » [Plugin: Google Analytics for WordPress] Does this pluging use the new Events Tracking feature?

  • There is a new way to track outgoing links and downloading files:
    _trackEvent.

    With this new feature every click on an outgoing link don’t count as page view, but count as a new Event “Outgoing link”.

    In this blog there’s a jquery code to track events:

    For outbound clicks

    $('a').click(function() {
      var $a = $(this);
      var href = $a.attr('href');
    
      // see if the link is external
      if ( (href.match(/^http/)) && (! href.match(document.domain)) ) {
    
        // if so, register an event
        var category = 'outgoing'; // set this to whatever you want
        var event = 'click'; // set this to whatever you want
        var label = href; // set this to whatever you want
    
        pageTracker._trackEvent(category, event, href);
      }
    });

    For file downloads

    var fileTypes = ['doc','xls','pdf','mp3'];
    
    $('a').click(function() {
      var $a = $(this);
      var href = $a.attr('href');
      var hrefArray = href.split('.');
      var extension = hrefArray[hrefArray.length - 1];
    
      if ($.inArray(extension,fileTypes) != -1) {
          pageTracker._trackEvent('download', extension, href);
      }
    
    });

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Google Analytics for WordPress] Does this pluging use the new Events Tracking feature?’ is closed to new replies.