I read this article about tracking outbound links on banners and such:
So I added this code to the onClick event of my href:
Is this enough?
Because I have read some places I need a “link delay” function or something in the
Also, where exactly in GA (in the interface) will I be able to view the clicks?
Here’s the problem: every item of data recorded & reported by Google Analytics is sent to the GA Servers in the Request URL component of a Request by the client for the __utm.gif. The function _.trackPageview() provokes the collection/concatenation of the data into a Request URL, as well as the Request itself. In other words, if _trackPageview() isn’t called, no data is sent to the GA Servers.
So the question is whether the GA Request (above) is processed before the Request associated with the outbound link. If it is not, then the click on the outbound link is not recorded by GA, which is not what you want.
So what you want to is delay, just slightly–long enough for the GA Request to occur but short enough so that the user doesn’t notice the delay–the outbound link Request.
There are a few differences between the code posted in your Q, and the code below–all diffs are directed to this ‘race condition’.
First, notice that the return value from the onClick handler is set to “false“–preventing the client browser from (immediately) navigating to http://www.outbound-link.com
The second diff is the call to setTimeout. The third argument passed in, ‘100’ is the number of milliseconds delay.
Third, the onclick handler (fnx) creates its own tracking object, and therefore doesn’t rely on a pageTracker object to have been initialized elsewhere.
Your second question is, where in the GA Browser do you view these clicks? Using GA, you can track events in two distinct ways–using _trackEvent() or _trackPageView().
By tracking outbound links the second way (as you did and therefore as i did below) the ‘click’ shows up not as an event, but as a pageview (‘virtual pageview‘ is the term most often used by the GA Consultants, et al. to indicate something tracked as a page view but which is actually not). So you will see these clicks reported along with other page views–i.e., in Content (along with Traffic and Visitors, the three main headings in the left-hand panel). How can you tell which lines in that report refer to the these outbound clicks? The value of the Page field (usually the left-most column heading) will be the url of the outbound link. Once you know this, of course, you can create an Advanced Segment or Custom Report or even a new Profile, to report these separately.