navigation - inserting google 'onclick' tracking link attribute in wordpress -
i looking way modify links on wordpress site tracks 3rd party links.
i able find the, how create correct tracking code in google analytics, second part of process add specific link attributes.
here example suggest replicate:
<'a href="www.blog-hosting-service.com/myblog" onclick="_gaq.push(['_link', 'www.blog-hosting-service.com/myblog']); return false;">view blog
does know can insert code link attributes can collect external clicks via google analytics?
jquery best way in opinion.
// start getting current page path (the 1 sending tracker) var pathname = window.location.pathname; // ready handler change links on hosts not equal location host $(document).ready(function() { $('a[href^="http://"]').filter(function() { return this.hostname && this.hostname !== location.hostname; }).click(function(e) { _gaq.push(['_link', pathname]); }); });
Comments
Post a Comment