Thursday, August 27, 2009

Webtrends: Tracking Offsite Links

So, you got SDC set up and running for you...

Ah.. What kind of setup is that?
One DCSID for all sites or Unique for each?
I prefer one DCSID for all, shall tell you later why.

Anyways, so I get this query often to how to track Offsite links. Moreover, because I convinced my clients by saying they track downloads and off site links Out Of the Box without any onclicks to be put. Just place the tag in the footer and they're good to go. :)
Believe me the smile is wide on the clients face and wider on the developers face.
So, after few months I realised that webtrends does tracks offsite links but logs it in the log file as an offsite hit than an on-site hit.

e.g.
Suppose the on-site domain field contains: localhost,webtrends.corp
Page contains the following hyperlink:

(Values taken from tagbuilder.webtrends.com to explain in an easier way)
Wikipedia
Clicking the link generates the following parameters:
DCS.dcssip=wikipedia.org
DCS.dcsuri=/wiki/Web_analytics
DCS.dcsref=page/clicked/on.aspx
WT.ti=Offsite:wikipedia.org/wiki/Web_analytics

Than

DCS.dcssip=webtrends.corp
DCS.dcsuri=wikipedia.org/wiki/Web_analytics or /page/clicked/on.aspx
DCS.dcsref=/page/clicked/on.aspx
WT.ti=Offsite:wikipedia.org/wiki/Web_analytics

How does one know the offsite visits?
All you got to do is search for "OFFSITE" in page titles in pages report for offsite links clicked. However, if you have aggregation of domains turned on for the profile that would go haywire with no domain and just page url listed. It would also be listed under exit pages in this scenario.

You would be lucky if you have a SDC setup where Sites have unique DSCID and profile's based on DCSID or have different logs for every DSCID than a domain filter.

As in case of a doman filter profile the present offsite link would not be included else you know all the offsite link domains and don't mind creating an include filter for them one by one.

There's always light at the end of the tunnel,
Yeah it depends on your luck, if it's actually the end or a train heading towards you.

Well, I did get to the end of the tunnel...

So why on earth would I do a single DCSID for all sites and take the pain to do the offsite mod's.

I have a SDC setup where there's one DCSID for all sites and makes one logfile for all sites.

Advantages:

1) One DSCID for 1000's of site no confusion or regular DSCID generation.
2) One script to provide to the dev team.
3) No updating SDC with DCSID's and stopping and restarting SDC. Set It, Start It, forget it...
4) One log file to transfer every hour or day.
5) Much easier to maintain if you have an SDC farm of 3-4 servers or more.
6) One datasource & Profile in UI. Just make a template profile and keep reusing it by making a copy, Ah just remember to change the multi homed domain filter for each new site profile.

Disadvantages:
1) Size of logfiles
2) Troubleshooting hits to SDC from sites, one needs to filter the log and then look at it.
3) Tracking offsite links as one would be using domain filter which would include one on-site domain enteries.

Here's what I did to improvise offsite tracking.
This works best for all setups.

Changes done:

1) It now logs as hit to on-site than to off-site.

Earlier: DCS.dcssip=wikipedia.org
After Mod: DCS.dcssip=webtrends.corp

Now it will be included in domain filter profiles also.

2) Dcsuri is the page the offsite link was clicked on and hard coded with prefix "/offsite/"

DCS.uri=/wiki/Web_analytics (offsite page)
DCS.uri=/offsite/page/clicked/on.aspx (onsite page with offsite as prefix)

This is done so that it doesn't add to page views of the on-site page and lists under pages report as well as exit pages.

3) New Parameter: WT.Offsite

WT.offsite=wikipedia.org/wiki/Web_analytics

Create a new report called Offsite links using this parameter.
To track multiple links to the same page from different onsite pages, one can use parameters.

Hereby is the original code:
// Code section for Track clicks to links leading offsite.
WebTrends.prototype.dcsOffsite=function(evt){
evt=evt||(window.event||"");
if (evt&&((typeof(evt.which)!="number")||(evt.which==1))){
var e=this.dcsEvt(evt,"A");
if (e.href){
var hn=e.hostname?(e.hostname.split(":")[0]):"";
var pr=e.protocol||"";
if ((hn.length>0)&&(pr.indexOf("http")==0)&&!this.dcsIsOnsite(hn)){
var qry=e.search?e.search.substring(e.search.indexOf("?")+1,e.search.length):"";
var pth=e.pathname?((e.pathname.indexOf("/")!=0)?"/"+e.pathname:e.pathname):"/";
this.dcsMultiTrack("DCS.dcssip",hn,"DCS.dcsuri",pth,"DCS.dcsqry",
this.trimoffsiteparams?"":qry,"DCS.dcsref",window.location,
"WT.ti","Offsite:"+hn+pth+"?"+qry,"WT.dl","24",
"WT.nv",this.dcsNavigation(evt));
this.DCS.dcssip=this.DCS.dcsuri=this.DCS.dcsqry=this.DCS.dcsref=
this.WT.ti=this.WT.dl=this.WT.nv="";
}
}
}
}

Hereby is the modified code:
// Code section for Track clicks to links leading offsite.
WebTrends.prototype.dcsOffsite=function(evt){
evt=evt||(window.event||"");
if (evt&&((typeof(evt.which)!="number")||(evt.which==1))){
var e=this.dcsEvt(evt,"A");
if (e.href){
var hn=e.hostname?(e.hostname.split(":")[0]):"";
var sam=window.location.hostname;
var pr=e.protocol||"";
if ((hn.length>0)&&(pr.indexOf("http")==0)&&!this.dcsIsOnsite(hn)){
var qry=e.search?e.search.substring(e.search.indexOf("?")+1,e.search.length):"";
var pth=e.pathname?((e.pathname.indexOf("/")!=0)?"/"+e.pathname:e.pathname):"/";
this.dcsMultiTrack("DCS.dcssip",sam,"DCS.dcsuri","/offsite"+window.location.pathname,
"DCS.dcsqry",this.trimoffsiteparams?"":qry,"DCS.dcsref",window.location,
"WT.ti","Offsite:"+hn+pth+"?"+qry,"WT.offsite",hn+pth+"?"+qry,
"WT.dl","24","WT.nv",this.dcsNavigation(evt));
this.DCS.dcssip=this.DCS.dcsuri=this.DCS.dcsqry=this.DCS.dcsref=
this.WT.ti=this.WT.dl=this.WT.nv="";
}
}
}
}


Awaiting critics or suggestions for improvisation...

Hope this helps everyone.

Ping me at samratdsouza@gmail.com for any issues, glad to help.
(No Monetary benefits expected)