Google Translate

Sunday, April 25, 2010

Omniture plug-in: “setCampaignVars” for efficient campaign tracking

WARNING: this is a very technical entry that details some web programming/development for a specific web analytics tool.

(This entry was originally published on the XM Asia Pacific blog. I'm reproducing it here as my publishing and reproduction right as the plug-in's sole developer.)

Today, I'm proud to share a plug-in that will help to make campaign tracking more efficient within Omniture's s_code.js file 1. It's called setCampaignVars. It's free, it's easy to use, and -- best of all -- it's open source.

Background: Campaign Tracking with Omniture SiteCatalyst
At its simplest level, campaign tracking works this way: the Omniture code reads a value from the URL and saves it as your campaign tracking code. For example, let's say that I have the following URL:
The Omniture code can be configured to get the campaign tracking code whenever it sees the "cmp" query parameter in the URL. In this example, it will save foobar as the tracking code.

But Omniture recommends that campaign tracking doesn't stop there. It suggests the following:
  • Store the tracking code in an Omniture traffic variable - to report on pageviews, visits, time spent, and similar metrics
  • Store the tracking code with your landing page name and enable pathing on this combination - to track how users navigate your site from the landing page
In addition, depending on your requirements, you might also need to
  • Make the user's browser retain the tracking code for a period of time 2, regardless of how he subsequently returns to your site.
Campaign Tracking introduces New Problems
To implement the above, your Omniture technical account manager should have provided you with a set of code that you can just copy-and-paste into your s_code.js file, or the file may already contain the code when it was first given to you. That's all well and good. BUT (and you knew there would be a "but"), that code normally applies for external campaigns only, for example, to track users who enter your site from a paid search campaign.

On the other hand, you may have internal campaigns, e.g. banners within your site, like on your homepage, for certain promotions. You'd want to track these in the same way as external campaigns. (Omniture recommends that you do so too.) But that means you'd have to (a) write the code yourself, or (b) get your account manager (or savvy web developer) to do it for you.

New Problems demand a New Solution: setCampaignVars
Now I give you option (c): setCampaignVars. After adding the plug-in to your s_code.js file, you will be able to:
  1. Get the (external or internal) campaign tracking code from your URL
  2. Store the tracking code in both traffic and conversion variables
  3. Store the tracking code+landing page combo as a traffic variable for pathing (optional), and
  4. Retain the tracking code only once for a certain period of time (optional)
Here's how to use setCampaignVars:
  1. Get the file, setCampaignVars.txt
    • Refer to setCampaignVars_maximized.txt for the plug-in's details and its "maximized" version
  2. Copy-and-paste the contents of setCampaignVars.txt into your s_code.js after "PLUGINS SECTION"
  3. Make sure your s_code.js contains Omniture's getQueryParam, getAndPersistValue and getValOnce plug-ins
  4. Use setCampaignVars within the s_doPlugins block
Getting Started with setCampaignVars
Here are a few example scenarios to get you started with step 4:
  • Save your external campaign tracking code (from the "cmp" URL query) to s.campaign and s.prop1, and expire the tracking code within the same visit
  • Save your external campaign tracking code (from the "cmp" URL query) to s.campaign and s.prop1, keep the tracking code for up to 7 days, and enable campaign pathing (using ":" to separate the tracking code from your landing page name) on s.prop2
  • Save your internal campaign tracking code (from the "intcmp" URL query) to s.eVar7 and s.prop7 and retain the code for the next 30 days
Now It's Your Turn
I've used setCampaignVars with great success for a major project. Knowing that it works properly in a production environment, I'm now making it publicly available for the Omniture community to use as well. Hopefully, it makes your lives much simpler, as it did mine.

If you encounter any implementation errors with setCampaignVars, please log it down at the setCampaignVars support section in SourceForge. Or help me fix it 3.

Disclaimer: setCampaignVars is not endorsed, verified or supported by Omniture. Use at your own risk. Also, by using this code, you agree not to hold XM Asia Pacific or any of its employees, both past and present, liable for any data errors and/or loss.

  1. The "s_code.js" file is a required JavaScript file that performs the guts of web tracking for Omniture's tools.
  2. The retention period for your campaign tracking code is measured in days. Ideally, it should match your campaign variable's setting within your report suite's Administration section.
  3. setCampaignVars is entirely open source and licensed under the GNU General Public Licence v3.

No comments:

Post a Comment