Google    
Conversion University
Change Language:
Google Analytics Home > Conversion University > Outcomes

    

Tracking Offline Campaigns

by Amit Singh

You can use Google Analytics to track campaigns that refer visitors to vanity URLs. On print ads, for example, it's common to provide a URL that's unique to the campaign. By tracking traffic to the vanity URL and the conversions that result from this traffic, you can track the success of the campaign.

In order to accurately attribute conversions to the offline campaign, you'll need to tag all visitors to the vanity URL with campaign variables. This article describes three ways of doing this.

As an example, let's imagine that www.googlestore.com runs an offline print campaign which points readers to the googlestore.com/coolstuff vanity URL. In order to track the online conversions that result from this offline print campaign, we'll tag all visitors to googlestore.com/coolstuff with a source of "offline", a medium of "print" and a campaign of "Coolstuff".

Approach #1 - Meta Refresh

This approach allows you to tag all visitors to the URL, even those who may have been referred to the URL via a link. In this approach, when a browser client requests a URL associated with an offline campaign (for example, the www.googlestore.com/coolstuff for our hypothetical campaign), the web server can return an HTML document containing a meta-refresh tag which redirects the visitor to the appropriate landing page.

The HTML code is

<html>
<head>
<title>Coolstuff</title>

<!-- Include the Google Analytics tracking code to additionally track page views of /coolstuff i.e. the redirect page. This step does not affect offline campaign tracking.-->

<!-- INSERT YOUR GOOGLE ANALYTICS TRACKING CODE HERE -->

<meta http-equiv="refresh" content="2; url=/details/coolstuff.html ?utm_source=offline &utm_medium=print &utm_campaign=Coolstuff">
</head>
<body>
.
.
.
</body>
</html>

While this approach will satisfy most needs, it has the following drawbacks. First, there is no guarantee that the JavaScript tracking code will complete execution before the page redirects. One solution to this is to wait two seconds before redirecting, thereby reducing the chance of the pageview not being tracked.

The second drawback is that it does not exclude visitors who may have clicked the link and who were therefore not really referred by the offline campaign. There is, however, a way of excluding visitors who clicked the link online; see Approach #2.

Approach #2 - Exclude Referrals.

Use this approach if you want to include in your campaign tracking only visitors who actually typed the URL into their browser.

The HTML code is

<html>
<head>
<title>Coolstuff</title>
<!--
Include the Google Analytics tracking code to additionally track page views of /coolstuff i.e. the redirect page.
This step does not affect offline campaign tracking.
-->

<!-- INSERT YOUR GOOGLE ANALYTICS TRACKING CODE HERE -->
/*

Function redirect(destination, source, medium, campaign)

Redirects user to the destination page.

If user typed URL in the address bar, additionally adds campaign variables. Does not add campaign variables for users coming from clicks. Reads the document.referrer property to check if user typed web address.

*/
function redirect(destination, source, medium, campaign)
{
if ( ! top.document.referrer || top.document.referrer == "" )
{
if ( source && medium && campaign )
{
destination = destination + "?" + "utm_source=" + source + "&" + "utm_medium=" + medium"&" + "utm_campaign=" + campaign;
}
}
window.location.href = destination;
}

</script>

</head>
<body
onload="redirect('/details/coolstuff.html', 'offline', 'print','Coolstuff')">
</body>
</html>

Approach #3 - No redirect is needed because the destination URL contains the content.

Let's assume that googlestore.com/coolstore contains all the content and there is no need for a second page. In this case, you'll need to reload the page with the campaign variables appended to the URL.

The HTML code is

<html>
<head>
<title>Coolstuff</title>

<!--
Include the Google Analytics tracking code to additionally track pageviews of /coolstuff i.e the redirect page. This step does not affect offline campaign tracking.
-->

<!--
INSERT YOUR GOOGLE ANALYTICS TRACKING CODE HERE
-->


function addCampaignTagsAndRedirect(source, medium, campaign)
{
var url = top.location.href;
if (
url.indexOf('utm_source') == -1    &&
url.indexOf('utm_medium') == -1    &&
url.indexOf('utm_campaign') == -1
)
{
top.location.href = url + '?' +
    'utm_source=' + source + '&' +
    'utm_medium=' + medium + '&' +
    'utm_campaign=' + campaign;
}
}

</script>
</head>
<body onload="addCampaignTagsAndRedirect('offline', 'print', 'Coolstuff')">
.
.
.
</body>
</html>

To prevent duplicate visits from affecting report data, you will need to add an exclude filter ignoring request stems of type /coolstuff (i.e. without the query parameters). Add this filter to your profile.

Search Help Center

Can't find an answer to your question? Contact us