Time spent by Traffic Source

Share this article

One of the things that’s not “native” to SiteCatalyst reporting is Time Spent by Referring Domain, which can be quite a useful segment to use.  So here’s a quick tip to get it working.

The report below shows the end result; Time Spent by Traffic Source (a new custom insight prop).  The entry marked as “direct” are visitors that had no referrer string.

time_by_referrer

Time Spent is enabled by pathing a traffic prop (custom insight).  So to get Time Spent by Traffic Source you need to do a couple of little things.

Step 1 – Create a Prop

In the admin, create a new traffic prop and an eVar (if you want conversions by this too).  I named mine Traffic Source (p) and Traffic Source (c) – just to not confuse them with the native Referring-based reports.

Then ask Client Care to enable pathing on the traffic prop.

Step 2 – Modify your s_code

The following snippet of code should be added into your s_code, along with all of your other rules.  I’ve used s.prop7 and s.eVar16 for my new Traffic Sources reports.

[javascript]
/* Set persisting referrer */
if(document.referrer){
s_trafficsource = document.referrer.split(‘/’)[2]; //get the host
if(s_trafficsource != window.location.host){
s.prop7=s.getAndPersistValue(s_trafficsource,’s_referrer’,7);
s.eVar16 = s.prop7;
} else {
// same referrer as site
s_prop7=s.getPreviousValue(s.prop7,’gpv_ref’);
s.prop7=s.getAndPersistValue(s.eVar16,’s_referrer’,7);
s.eVar16=s.prop7;
}
} else {
// no referrer – so direct
s_trafficsource = “direct”;
s.prop7=s.getAndPersistValue(s_trafficsource,’s_referrer’,7);
s.eVar16=s.prop7;>
}
s.prop7=s.getAndPersistValue(s.eVar16,’s_referrer’,7);[/javascript]

You’ll see from the above that it also uses the getAndPersistValue and getPreviousValue plugins.  If you don’t have them they are available for download through the Help section of SiteCatalyst.

Basically, if there’s a referring domain, it’s initially set and persisted through the getAndPersistValue plugin.  Then it’s passed from page to page via the combination of getPreviousValue and getAndPersistValue.

For those that don’t have a referrer, then it’s just set as “direct” initially and then persisted.

And that’s all there is to it. The pathing reports that this enables actually don’t show too much so you might want to disable them (they do show multi-traffic sources during the same visit though).


Share this article