1

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:

 onclick="_gaq.push(['_trackEvent', 'Banners', 'Clicks', 'Banner Name (ID: 101)']);"

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

Darren.

2 Answers 2

3

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.

2
  • Decided to just port it over to Google DFP. Commented Jul 20, 2010 at 17:16
  • Link to Google's recommendation is broken.
    – Seybsen
    Commented Nov 15, 2012 at 7:41
0

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.