gaAddons Free!

This code is provided as is, without any support or guarantee.

by Stéphane Hamel

JavaScript

// gaAddons FREE v1.0, Copyright 2011, Stephane Hamel - http://gaAddons.com
// Licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
// gaAddons FREE v1.0, Copyright 2011, Stéphane Hamel - http://gaAddons.com
// gaAddons by Stéphane Hamel is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// This code is provided as is, without guarantee or support.

///////////////////
// _formAnalysis: not provided - use ClickTale!

///////////////////
// _setDayOfWeek: obsolete - this metric is available within GA

///////////////////
// _setDualMode: not provided - refer to _setLocalRemoteServerMode documentation on GA website

///////////////////
// _setXDomain: multiple top domains & sub-domains
var crossDomains = '(mysite.com|myothersite.com)'; // regex matching the list of top domains you own
var baseDomain = location.hostname.match(RegExp(crossDomains + '$'));
baseDomain = (baseDomain ? baseDomain[1].replace(/\:\d+/, '') : location.hostname);
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-99999999-9']); // change the UA account!
_gaq.push(['_setDomainName', baseDomain]);
_gaq.push(['_setAllowLinker', true]);
(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

jQuery(document).ready(function($) {
    // for any link starting with http, but not pointing to the current domain or any of its subdomains, but matching one of our tracked domains...
    $('a:regex(href,^http[^/]+' + crossDomains + ')').live('click', function(e) {
        if (this.href.match(crossDomains)[1] != baseDomain) {
            var t = _gat._getTrackerByName();
            this.href = t._getLinkerUrl(this.href);
        }
    });
});

///////////////////
//...