开发者

Google Analytics External Link Tracking

开发者 https://www.devze.com 2023-01-03 15:13 出处:网络
I\'m using event tracking to monitor external links, but I\'m wondering if the tracking will be done before the link is fired. I\'m using the onclick:

I'm using event tracking to monitor external links, but I'm wondering if the tracking will be done before the link is fired. I'm using the onclick:

开发者_C百科 onclick="_gaq.push(['_trackEvent', 'Banners', 'Clicks', 'Banner Name (ID: 101)']);"

Any ideas, or better ones if that's a bad way?! Thanks!

Darren.


Your implementation is fine, and it's exactly how Google recommends.

but I'm wondering if the tracking will be done before the link is fired. I'm using the onclick

the event won't be tracked until the user clicks the link, once they do that it's a race between the event tracking and next page load starting. Usually your event will be tracked, but sometimes it is not. There are two mostly similar methods to avoid the race condition:

  1. Google's recommendation.
  2. My recommendation.

Both help articles don't really address the async option, but it doesn't take much changing.


If you are using jQuery and want to automatically track all external links check out the script in this answer: https://stackoverflow.com/a/12326388/984780

Also not it uses the async method of invoking Google Analtyics. Also you can easily tweak the timing to ensure that the event gets tracked.

0

精彩评论

暂无评论...
验证码 换一张
取 消