/*
* Outbound and file tracking script for Google Analytics
*
* Author: Rod Jacka
* Company: Panalysis Pty Ltd www.panalysis.com
*
* Panalysis are Authorised Google Analytics Consultants and can assist you to
* correctly implement and interpret the reports from Google Analytics.
*
* See http://googleanalytics.panalysis.com/ for details
*
Copyright Panalysis Pty Ltd 2006-2007 all rights reserved
* You may freely modify, use and distribute this script provided that
* this message is retained. The use of this software is subject to the terms of the
* GNU General Public License which can be viewed at http://www.gnu.org/copyleft/gpl.html
*
* Description: Automatically captures clicks to specified non HTML documents and
* links to other websites and feeds these into the Google Analytics tracking code
* version 1.02
*
* To install download this file to your web site and save to a known location e.g.
* root level of the site or an includes directory. Be sure to save the file as outbound.js
*
* Add the following line below your current Google Analytics code
*
*
* Be sure to change the src="/outbound.js" value to match your own installation
*
* For a modest fee, Panalysis can install and configure this script for you.
* Version 1.0.1 - Added function to record transaction in an alternative Google Analytics account
*
*/
var whoami=navigator.userAgent.toLowerCase(); //use lower case name
var is_firefox = (whoami.indexOf("firefox") != -1); //does name contain 'firefox'?
var is_ie = (whoami.indexOf("msie") != -1); //does name contain 'msie'?
function getOutBoundLink(e){
var targ;
var url,dest;
var base = "/outbound/";
var includeTypes = Array("pdf","doc","rtf","swf","exe","xls","csv","tsv","ppt","mov","mp3","wmv","html");
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
if(targ.ELEMENT_NODE != undefined)
{
while(targ.nodeType != targ.ELEMENT_NODE)
targ = targ.parentNode;
}
// handle whether the link is an image based link
if(targ.nodeName == "IMG")
{
targ = targ.parentNode;
}
if(targ.href != undefined)
url = targ.href;
else if(! is_ie && ! is_firefox && targ.target != undefined)
url = targ.target;
if(self.urchinTracker && url != undefined)
{
var re1 = new RegExp("http[s]?:\/\/([^\/]*?)(\/.*)");
var re2 = new RegExp("file:\/\/(.*)");
var m = re1.exec(url);
if(m)
{
if(m[1] != window.location.host)
dest = base + m[1] + m[2];
else
{
var testURL = m[2]; // it is an internal link
var el = testURL.split(".");
var ln = el.length - 1;
var testEx = el[ln].toLowerCase();
var isOK = false;
for(var x=0; x