« »
Oct 11
2010

Recently, I had a conversation with some web analysts about the different traffic attribution models in Web Analytics.   This is a topic that web analysts and marketers will never reach an agreement on!  A few days after the dry theoretical discussion, I got a request from one of our clients to change the traffic attribution model in Google Analytics to treat “direct” traffic like any other traffic sources, which will enable them to measure the impact of their branding efforts.

What is considered “direct traffic” in Google Analytics?

Direct Traffic represents visitors who typed the URL directly into the web browser, clicked on a bookmark to arrive at your site, or clicked on an untagged URL in a desktop based application that link to your site.

What is the issue:

By default, Google Analytics attributes a visit and its conversions and sales to the last traffic source; that is what we call Last Click Attribution model. An exception to this rule is a “direct” visit. If a visitor returns to a site directly, the last traffic source before the direct visit will still get credit for that visit’s activities. This behavior is disliked by (few) analysts who prefer to look at the “direct” traffic like any other traffic sources.

Here is a simple example to illustrate the issue:

You are a web analyst at forever21… you ran a huge online campaign for the back to school sale (banner, email, social media, affiliate,..) now you want to measure your brand awareness in the market. You want to see how many people because of your branding efforts visit your website directly by typing your URL?

A few months after the end of the campaign you still see visits are tracked as “paid search”, “email” and “banner”. You see a very small number of “direct” visits. In the budgeting meeting you shared the numbers with the board and you decided to spend more $$$ on marketing because you haven’t reached your brand awareness goals yet.

Hold on! Do you know that most of these “paid search”, “email” and “banner” visits that you see today in your report are “direct” visits?These campaigns did their job months ago and now the whole universe knows about your brand and comes to your site directly.  Unfortunately, you have no insight about these “direct” visits because of the rule that “direct” visits do not override previous traffic sources for 6 months!

Can we change this rule? If this will answer your business needs and save you money, of course we can :)

Solution:

Simple! Just credit visits to the last campaign/traffic source regardless of whether the visit was a direct or non-direct visit. See the table below for a comparison between the default GA reporting settings and the “True Direct” solution settings:

Visitor Visit 1 Visit 2 Visit 3 Visit 4
Source / Medium cnn.com / Referral ask / organic Direct Access Bookmark
Last Click Attribution cnn.com / referral ask / organic ask / organic ask / organic
True Direct Attribution cnn.com / referral ask / organic direct / none direct / none

How:

We will need to run some JavaScript code before firing the Google Analytics tracking code. This JavaScript code will check:

  • the value of the URL of the page that loaded the current page (Output: URL or Null)
  • the current page’s URL (Tagged with Google Analytics campaign UTMs or not tagged)
  • if the value of the referring page is NULL and the current URL doesn’t contain any UTMs, then update the URL with the following utm parameters utm_source=(direct)&utm_medium=(none)&utm_campaign=(not set)

Why do we check whether the current page is tagged or not?

Sometimes pages are loaded without referring information, yet they might have been manually tagged with campaign parameters to force GA to credit the visit to a certain channel. We do not want these pages to be overridden by our “direct” parameters.

Example: http://www.mysite.com/myfile.html#utm_source=cnn.com&utm_medium=banner&utm_campaign=thanksgiving

The traffic source for this visit will be:

  • Source = cnn.com
  • Medium = banner
  • Campaign = thanksgiving

Click here to view the entire code segment

Let us explore the code, section by section:

function get_referrer() {
var source = document.referrer;
if (source == null || source == “”)
return “direct”;
}

This portion of the code will determine the URL value of the page that loaded the current page (referring page). If the value is NULL, the function will return “direct” indicating that the current page was not referred by another site.

function get_parameter() {
var urlstr = window.location.href;
var results = urlstr.match(/[\\?&#]utm_source=([^&#]*)/);
if (results != null)
return “tagged”;
}

This portion of the code will determine if the current page is manually tagged with Google Analytics campaign parameters.

if (srcPage == “direct” && parameter != “tagged”) {
window.location.hash = “utm_source=(direct)&utm_medium=(none)&utm_campaign=(not set)”;
}

This portion of the code will check the values returned by the two functions above. If the visit has no referring information (direct) and the URL is not tagged with any Google Analytics campaign UTMs, then the page URL will be updated with Google Analytics UTM parameters setting the source and medium for the visit to “direct”

Page URL
http://www.mysite.com/myfile.html
New URL
http://www.mysite.com/myfile.html#utm_source=(direct)&utm_medium=(none)&utm_campaign=(not set)

* Notice that we did not use window.location.href function because this function will reload the page with the new URL, which is not what we want to happen. We just want to update the URL, without affecting the visitor experience, in order for the Google Analytics tracking code to attribute the visit in a certain way.

Bonus: Defining a Search Term as Direct Traffic

Sometimes out of convenience or laziness visitors reach your website by entering your domain name or business name as a search term in a web search engine (ex. google, yahoo, bing). Those visits will be attributed in GA as organic search visits, even though, the only difference between the two visits is that in one visit the URL was typed into the web browser’s address bar and the other was typed into the browser’s search box.

In my opinion, these branded searches should be dealt with as direct visits. In GA we have the option to do that so if you are convinced, then let’s configure Google Analytics to treat certain search terms (our brand) as direct traffic.

The configuration has to take place at the code level. It will be simply adding the _addIgnoredOrganic() method inside the Google Analytics tracking code for each keyword we want to track as direct traffic.

The custom Google Analytics tracking code will look like this:

<script type=”text/javascript”>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-x']);
_gaq.push(['_setAllowAnchor', true]);
_gaq.push(['_addIgnoredOrganic', 'e-nor']);
_gaq.push(['_addIgnoredOrganic', 'e-nor.com']);
_gaq.push(['_addIgnoredOrganic', 'www.e-nor.com']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

Congratulation, now you don’t only have access to the direct visits data of those who visit your site for the first time as direct, but you will have insight into all direct visits regardless of whether they took place during the first, second or even the tenth visit.

Related Posts

Tags: ,

7 Responses to “Measure Impact of Brand Marketing Using Google Analytics”

  1. I think it’s a great idea to start reporting ‘true direct’ traffic as such, so thank you for providing the detail on how to do so. The current situation is one which many people misunderstand, as you point out.

    It’s a shame that we’ve been stuck with the current use of the word ‘direct’ for historical reasons. Something like ‘unattributed’ or ‘unknown’ would have been more accurate. But no vendor was ever going to use a word which described an absence of information implied that they just didn’t have any detail on the origin of a visit.

    In picky mode I would re-write your description:
    “Direct Traffic represents visitors who typed the URL directly into the web browser, clicked on a bookmark to arrive at your site, clicked on an untagged URL in a desktop based application that link to your site, or do not have any explicit origin details for some other reason.”

    I’m not so sure about using _addIgnoredOrganic though. That seems to be going in the opposite direction: describing a visit which did start on a search engine as if it didn’t. When the visitor typed in that navigational search they may well have been exposed to other results, paid and unpaid, and their confirmation of their choice of your site says something.

    I would prefer using some kind of ‘rolled-up’ reporting of the relevant keywords, which could currently be done by using a filter to re-write the keywords with something like ‘Brand’. What I’d really like, of course, would be the ability to do that within the reporting interface!

  2. Tim: Thanks for sharing the real description of “direct” traffic. As for the use of _addIgnoredOrganic, I agree it should be used with caution since the customization is taking place at the code level.

  3. Chris says:

    Hi Allaendin,

    I am thinking that a small change to your approach might make it even more flexible. Rather than set window.location.hash, which commits you to one attribution model, instead set a custom variable and then at query time implement whichever attribution model you need using advanced segments. But the main logic would be the same – lookimg at the document.referrer and window.location.href to get your own view of attribution. This was just a thought experiment on my part so my logic may be flawed.

    - Chris

  4. Chris: The “custom variable” with “Advance Segment” option is very valid. It depends on how you like to look at your reports.
    For those who like to create separate profile for each traffic source for deep analysis cannot use the “custom variable” option since as of today we cannot create profiles in Google Analytics based on “custom variables”… I am sure it is coming soon though :)

    Thanks for reading,

  5. Rocky says:

    I am surprised that the client’s request to treat the “direct traffic” label in GA as “a measure of their branding efforts” was not countered with a correction to their incorrect underlying assumption.

    For most sites, little of the “direct traffic” visit group is actually bookmarks or typing in. The vast majority is usually email (using a client) or links that used javascript to open your site in a new browser window. There are other reasons for not having a referrer recorded, but these are the big ones. In no way are email clicks or links on another site an indication of brand recognition or recall.

    You can easily see that this group is a very large one if you can isolate your email, banner, or paid search visits using tracking placed in the landing URL. If you run a referrers report on just these three groups, you will see very large amounts of so-called “direct” traffic, despite the fact that these visits are almost certainly from banners or email or paid search.

  6. I am one of those analysts who think Direct traffic should be treated like any other traffic source, it makes the data a lot cleaner. However, while I have never actually done this, wouldn’t it be easier to just set the campaign cookie life to zero rather than 6 months using the _setCampaignCookieTimeout() code? This means the cookie is deleted when the browser closes and since GA uses last click attribution, the only impact is to not have campaigns override Direct – I think.

  7. Rob Kingston says:

    I like this post. I’m not sure if I’m prepared to make a code-level change to my main GA code but perhaps you could use two tracking objects on the site:

    i.e. see how I have created two tracking objects when tracking page load times? http://www.optimisationbeacon.com/analytics/track-page-load-times-with-google-analytics-asynchronous-script/

    Also another consideration to make with this alteration is that visitors whose sessions timeout during making a purchase (as it often does when they check their bank account details / facebook), will be attributed to Direct.

    What you might want to do then, is set the session timeout to a higher number: http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._setSessionCookieTimeout

    Hope that helps. Great post by the way Allaedin. looking forward to more…

Trackbacks

  1. | Gubar.hu

Leave a Reply