December 4, 2011 ↘︎

Time spent by Traffic Source

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 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.

/* Set persisting referrer */
s_trafficsource = document.referrer.split(‘/’)[2]; //get the host
if(s_trafficsource !={
s.eVar16 = s.prop7;
} else {
// same referrer as site
} else {
// no referrer – so direct
s_trafficsource = “direct”;

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).

DB logo
DB logo
DB logo