skip to main content

TAMU Webmaster's Blog


Information and insight from the A&M Webmasters

Google Analytics Tip

December 4th, 2008 by Erick Beck

For those of you who have been using Google Analytics and have been frustrated that it does not track the page hits for links leaving your site, there is now a solution.  A small bit of javascript can be added to each external link that will allow Analytics to count the page hit before the browser sends the user off to the page.

<a href="http://campusmaps.tamu.edu/"
onclick="javascript: pageTracker._trackPageview/outgoing/campusmaps.tamu.edu');">Campus Map</a>

I use the domain name as an identifier here, along with “outgoing” to easily identify this as an external link, but the syntax is completely customizable to your needs.

The javascript in the call is completely “progressive,” meaning that it does not interfere in the action of the browser click.  If javascript is installed and working the link will be counted, if it is not then the javascript will be skipped and the browser will take the visitor to the desired page.

There are only two caveats to this method:  first, it is only available with the new Analytics code, not with the older urchin.js code; second, the <script> block calling your analytics must be placed above these individual calls in the page flow rather than at the bottom of the page, as most of us prefer.

Thursday, December 4th, 2008 Analytics, Miscellaneous, Site Architecture
Share this article

1 Comment to Google Analytics Tip

  1. […] tracking, people are on your site, they click, and are gone forever. After stumbling on the article Google Analytics Tip by the Texas A&M Webmasters I decided to expand on […]

  2. Tracking outgoing clicks with Google Analytics | .eduGuru on December 5th, 2008

Leave a comment

Categories

Archives