Customize Code and Automatically Tag Outbound Links
Today we announce the roll out of two free Google Analytics tools: a tracking code generator and LinkTagger. These allow for easy customization of your Google Analytics tracking code and for automatic tagging of all your outbound links and downloads.
Tracking Code Generator
There are a number of common customizations that can be made to the Google Analytics tracking code. This code generator will step you through some of the most common scenarios and generate code accordingly.
Track Multiple Domains
The code generator will create custom versions of the code for each domain name you specify. It will also set the variables to allow you to track visits seamlessly as they go from one domain to the next.
Change the Visit Timeout
By default a visit to your site ends either when the visitor closes the browser or has been inactive for 30 minutes. If they don't visit any pages on your site within 30 minutes, the visit will end.
Use this code generator to change that window. If you have a content site that visitors tend to read periodically throughout the day but keep open in the background, you may want to increase the visit window. Or, if your site is content-light and visitors tend to come back frequently to check for updates or status, you may want to decrease the visit window so that each visit shows up as a distinct event.
Change the Marketing Window
Google Analytics tracks where a visitor came from for up to six months. For example, if you run a banner ad, visitors from the ad will be attributed to it until they come through a different ad or for six months, whichever comes first.
The code generator can set the window to a custom length. Some companies prefer to track a much tighter window for ads, like 30 days. After that, they don't want to see any traffic attributed to an ad. On the other hand, some prefer to attribute life-time value to an advertisement that brought a visitor to a site and would prefer to extend the window out as far as possible.
Track a Site in Multiple Accounts
If you need to track a website in multiple Google Analytics profiles or accounts, the tracking code generator can easily set that up for you. This might be useful if your marketing agency needs their own reports, for example.
Automatically Tag Links
LinkTagger is a fully customizable script for tagging everything from outbound links and downloads to cross-domain tracking. It consists of a script that goes on every page beneath the Google Analytics tracking code and a small file that gets uploaded to the root of your site.
LinkTagger eliminates the need to manually tag every link on your site. It eliminates the cost of verifying that no links were missed.
Track Downloaded Files
The LinkTagger script can automatically track as a pageview every time a visitor clicks a link to download a file. They get tracked as unique pages under their own virtual subdirectory.
Track Outbound Links
Any link that sends a visitor to a third-party site can be tracked with this script. The clicks will show up as pageviews under their own subdirectory. You can also specify domains for the script to ignore as outbound links.
Automatically Tag Cross-Domain Links
If your site uses multiple domains, you would normally need to edit the code for each page and then also add code to every link going between domains. This is a time-consuming effort, and some links inevitably get missed. LinkTagger will automatically tag every link for you if it leads to a domain you specify.














Comments
Was Causing Pop-up Window Problems in MSIE
I couldn't for the life of me figure it out, but I tracked it down to this code causing window.open links around my site to just die. The minute I removed it, they started working again.
http://www.codingforums.com/showthread.php?t=196732
No idea what was going on, but I can't use it because of my use of some small little pop-ups on my site.
-Jake
Great Tools!
These sound like they will save me *a lot* of time and effort on implementation--I'm excited to try them out!
--Sarah
Great tool but a couple of bugs...
Nice tool, but there are a couple of bugs:
1. setDownloadExtensions is spelled wrong in the .js file that you upload to your server (instead of Extensions, it's spelled as Extentions - with a 't') - this causes .js errors on the front-end.
2. In Internet Explorer, Google Analytics _utm values get attached to hypertext URLs. For instance, if you type a URL between the tags, such as http://www.mysite.com, the front-end text appears as http://mysite.com/?&_utma=1.12345&_utmb=1.234567... instead of just http://www.mysite.com.
Great tool overall, but #2 bug is almost enough to force me not to use it :(
Re: LinkTagger bugs
Thanks for your comment. The misspelling has been fixed. I recommend downloading the newest version.
Your second observation isn't a bug. If you're using multiple domains for one site, this is how Google Analytics passes the cookie information between domains. LinkTagger does this for you automatically. Otherwise, to achieve the same result, you have to manually tag every outbound link.
If this is happening for links that are on the same domain or that go to a third-party site you don't want tracked, it's because of whatever you passed to LinkTagger in the setCrossDomains() method. Refer to the instructions at the top of the linktagger.js file for more information.