How to monitor campaign performance in the Real-Time reports


Everybody who ever pays for traffic should be using campaign tracking! How else will you ever find out whether you spend your money wisely?

But how about monitoring a campaign in real time?

Well, Analytics has “Real-Time” — three “reports” or maybe “dashboards” that show data very quickly and refresh automatically.

Typical Real-Time Report in Analytics
The Real-Time reports are perfect if you want to do one of two things:

  • Have a dashboard on a screen that gives you a quick overview of what’s happening on your site right now, or
  • Monitor the result of something you did — launch a campaign for example

There is just one small issue: because data comes so quickly, there is no time to process it. What you see in the Real-Time reports is raw data. Which means: no persistence.

If you select a dimension that would normally persist, you get a warning

Warning in Real-time reports
What that means for monitoring campaigns is that you can see Click-throughs for your campaign, but not orders or other conversions that would happen later on the site.

But the second paragraph instills hope. There is a way.

We need to add two things to our setup:

  • save the tracking code somewhere when we get it, and
  • retrieve the tracking code when the conversion happens, and track it.

There a lot of ways to save and retrieve values on a site, the most straight-forward being: put it into a cookie. So that’s what we’ll do. You can also use localStorage or your session store, if you want.

For the remainder of this post, I’ll presume your tracking code comes in a URL parameter named “cid”, and that your conversion is a purchase (i.e. we’re looking for the “purchase” event).

Workaround w/o DTM

Both steps mentioned above can be easily handled by changing the doPlugins() method. Which is good, right?

The first piece of code that we need has to store the tracking code if there is one.

// step 1 - if there is a tracking code, store it
if (s.campaign) {
	// save it!
	s.c_w("s_tcstore", s.campaign);
	console.log("Saving tracking code '" + s.campaign + "' for later...");

The second piece of code we need has to read the tracking code and track it, but only if there was a conversion.

// step 2 - if this is a conversion, use the stored tracking code
if ("purchase") >= 0) {
	// load tracking code
	var tc = s.c_r("s_tcstore");
	if (tc) { // might be empty
		// track it
		s.prop6 = tc;
		console.log("Sent tracking code '" + tc + "' into prop6");

If you put those into your doPlugins() method, it should look like this:

Code within s.doPlugins()
Let’s see if it works. First, I call up the landing page with a tracking code on the URL.

Test: landing page
Then, I click through to the conversion page.

Test: conversion page
That is looking good, I’d say.

And the Real-Time report is agreeing with me.

Tracking Codes in Real-time Report

Workaround with DTM

What if you’re using DTM?

Well, the two parts of the Javascript above translate into two Page Load Rules. Rule 1 will handle the storage of the tracking code, while rule 2 will retrieve and track it.

Rule 1 — storage of tracking code

As above, we want this PLR to store the tracking code, if there is one.

The “if there is one” part translates into a condition within the rule.

Conditions for PLR 1
The three conditions in the screenshot are the most straight-forward ways of doing this, pick one in the following order:

  • Best — “Data Element” — this one is the most stable and will work in a wide variety of situations.
  • Ok — “URL Parameter” — this one only works if your tracking code is in a single URL parameter (like the “cid” that I suggested above), but it won’t really work for Google-style “utm_xyz” parameters, at least not 100% reliably.
  • Ok — “Custom” — flexible and versatile if you know what you’re doing.
  • Not so good — “JS Variable” — this one will only work if your Javascript variable is set before this rule fires. In most deployments, that would not be the case.

Wondering about the “.+”?

Regular Expressions and Values
If you enable “Regex” on the “Value” field, you can give the system a regular expression which it’ll try to match. In our case, “.” means “any character”, and “+” means “at least one of those”. So we’re testing that the value is actually not empty.

Storing the tracking code into a cookie can be done with Javascript, as above, but this time it is a bit easier, I think.

Using the “Add New Script” button in the “Javascript / Third Party Tags” section, create a new script and put this into it:

_satellite.setCookie("rttc", _satellite.getVar("Campaign Tracking Code"),0);

Yup, that’s it.

Rule 2 – tracking of stored tracking code

Before we make this rule, let’s make a Data Element that reads the cookie.

Data Element to be used for PLR 2
We’ll need that twice.

First, the conditions for the rule should be two-fold:

Conditions for PLR 2
Again, your choice between “Cookie” and “Data Element”. I would use “Data Element”.

Now we need to assign the value.

Setting the prop in PLR 2

An alternative approach could be to incorporate the storing of the tracking code into your standard page load rule. And you could absolutely use the DE for the stored tracking code in your standard “Thank you page” PLR.

I’ll leave that one to you, dear reader, as an exercise.

One thought on “How to monitor campaign performance in the Real-Time reports

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.