How SiteCatalyst’s getValOnce is Inadvertently Deflating your Data

For all you SiteCatalyst implementation experts out there – I’m sure you’ve used the getValOnce plugin at some point to help prevent inflating specific dimensions in your reports, such as external campaign code clicks, merchandising clicks, navigation elements, and the Channel Manager among other things. For those of you that don’t know what this plugin does, it’s used to determine if the last value passed for a specific variable over a certain amount of time is the same value and if so, set the value to an empty string instead (so nothing gets passed for the variable). Consider the following example:

We want to track internal campaign clicks by setting eVar12 to a query string parameter and setting a specific event to count the number of clicks. We also want to prevent the event from being inflated by users that would refresh the destination page or by clicking the back button, making it appear the user “clicked” on the same ad more than once. To prevent this, we would use getValOnce in s.doPlugins:

The last parameter of the getValOnce plugin determines the life of the cookie and when the value should be discarded. In the example above it’s set to 0, which creates a session cookie that should only last the duration of the user’s session. You would think this means when the user has been idle for more than 30 minutes the cookie gets erased, right? Wrong! It doesn’t get erased until after the browser/tab is closed. Instead of this being a “session” or visit, in normal web analytics terms (30 minutes of inactivity), it’s actually bound to the browsers definition of a session, which doesn’t end until after the browser or tab is closed.

Why is this a problem?
Let’s say you keep a few tabs open in your browser and go back to them when you have time during the day, as visitors often do on Reddit, news sites, Facebook, etc. Every time you interact with the site and break for more than 30 minutes, a new web analytics visit is started but the session cookie set by getValOnce never gets erased. That means if I interact with the same banner, navigation element, or any other requirement set using getValOnce, you may in fact be deflating total counts. This gets even worse for other plugins that rely on getValOnce, such as the Channel Manager, which won’t assign the channel as direct for this new visit. I guarantee anyone using the Channel Manager has an excessive amount of “None” values appearing in their reports which they’re unable to explain. This is why most of them might be populating!

Once I realized what was happening I had to come up with a solution or I wasn’t going to be able to sleep. Here’s how I fixed the problem with a little help from my friend Shawn Reed:

  1. I created a custom plugin which writes a cookie with a timestamp of the last image request directly after sending data to Adobe using a standard page view or event call.
  2. I updated the getValOnce plugin (using v1.1 as the basis) to check the timestamp of the cookie, and if greater than 30 minutes, erase the old cookie and accept a new value for the variable.

To implement everything above, add both plugins to your s_code file. If you’re already using the getValOnce plugin, make sure you comment it out or erase it completely. Lastly, add a call to s.__checkSessionCookie(); at the bottom of the s.doPlugins function (assuming s.usePlugins = true). See the example below:

That’s it! Obviously you should thoroughly test this in your development and staging environments before pushing to production. I’m happy to answer any questions you may have regarding this.

Helpful files to Download:

s.__checkSessionCookie

s.getValOnce_custom

 

 

By Kevin Wysocki
About the Author:

Kevin Wysocki is the Tag Management Practice Lead at Stratigent.

Contact Us Now