Articles written in June, 2009

June 26 2009

What is the “User Defined” report, and how do I use it?

by

User-Defined ReportHave you ever been in the Visitors section of your favorite Google Analytics profile and wondered what the heck “User-Defined” was? Did you ever want to know how you could make use of it? Do you have any idea what I’m talking about today? If you answered “Yes” to any of the three questions I just asked, continue reading.

Along with powerful features like Advanced Segmentation and Custom Reporting, Google Analytics allows the option for website owners to add an additional label to visitors who reach a certain point or complete a certain action on a website, such as visiting a key website page or purchasing something from a merchant’s online store. These labels are usually known as Custom Segments (or Custom Segmentation), and it’s a very powerful tool in obtaining deeper insights into website visitors who perform specific tasks and accomplish specific actions.

Making use of the User-Defined report in Google Analytics requires a bit of extra coding help from your IT department or webmaster, but it’s totally worth the short amount of time it takes to implement. For example, let’s say that I wanted to add a label of “customers” to any visitor who reaches my shopping cart’s “Thank You” confirmation / receipt page. What I would do is add an additional line of code to my Google Analytics Tracking Code (GATC), which would look exactly like this:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-XXXXXXX-1");
pageTracker._trackPageview();
pageTracker._setVar("customers");
} catch(err) {}</script>

Notice the line in bold that includes _setVar – when this is present on a page within the Google Analytics Tracking Code, an additional cookie – the __utmv cookie – gets set on a visitor’s computer, with its sole purpose being to identify the visitor by the label (or value) that you used in the code. If you notice up above, you will see “customers“, which was the label that I wanted to use.

Now, on their next visit to the site, they will be identified as a part of the “customers” segment in the User-Defined report, allowing you to perform analysis on all visitors who have purchased something from your online store. Neat, huh?

You can also use the pageTracker._setVar function when someone clicks on an important link on your site, or makes a key selection on an important form that you want visitors to fill out. For example, if you wanted to add a custom label to any visitor who clicks on your “Live Help” applet, you can ask your IT department or webmaster to add an “onClick” event, and give them the following line of code:

onClick="pageTracker._setVar('Needs Help');"

When all of your coding is complete, check the User-Defined report after about a day or so and you should see something like this:

Example of the User-Defined Report

Some things to note about Custom Segmentation / the User-Defined Report:

1. As we talked about, when a person visits a page calling the _setVar function, the __utmv cookie is set on their computer. This is a persistent, first-party cookie that has a lifetime of two years. This means that every time a user with a __utmv cookie returns to your site, the label assigned to the user will continue to identify them as such until they either delete the cookie or visit another page with another call to _setVar with a different label.

2. The purpose behind something like a User-Defined report – and Custom Segmentation in general – is that it is not designed to be updated very often. This label, for the most part, should be a permanent one for a visitor. You should only use _setVar on pages like a receipt page of a shopping cart, or an account registration “success” page for a visitor who becomes a member of your site. You shouldn’t use _setVar on your homepage, or use several different _setVar’s with different labels scattered across many pages of your website.

3. Google Analytics – at this time – only has the capacity to store one custom segment at any one time for one website. So if you are using multiple calls to _setVar on your site, Google Analytics can only store the latest value that a visitor runs into in the __utmv cookie.

4. However, Google Analytics uses what they call the “first association” of the session for visitor session calculations. So if you are using multiple calls to _setVar on your site, be aware that if a user runs into the first one, and then runs into the second one in the same visit, their Goal Conversion and Pages per Visit metrics would be attributed to the label of the first encounter with _setVar.

5. For page view calculations, Google Analytics uses the most recently defined value. So if a person runs into the second instance of _setVar on your site, all of their pageviews afterwards – including the current pageview – will be attributed to the second _setVar’s label, even though as we just learned in #4 above, visitor session information is attributed to the first encounter of _setVar.

A full, technical explanation of _setVar can be found here.

June 2 2009

Need to add a new organic source in GA? Here’s how:

by

Way back in August of last year, I blogged about the ga.js file and how it automatically recognized 38 different websites as organic search engines. Today, June 2, 2009, the ga.js file now automatically recognizes 40 websites, pending Microsoft’s new engine “Bing.com” being added very soon to be number 41.

The team at Google Analytics can’t possibly keep up with every single website that appears on the internet, and depending on your own needs, you may find it useful to count a new website as an organic source of traffic, instead of counting the incoming traffic as a referral.

Perhaps you’d like to count your favorite website as an organic search engine? Or maybe you’d like to add any brand new search engine that comes out, like WolframAlpha or Bing.com, and you’d like to immediately start counting the traffic you get from it in the same report as Google and Yahoo? By making a very minor addition to the Google Analytics Tracking Code on all of your website’s pages, you can add as many new organic sources of traffic as you wish.

Here’s what that tracking code would look like on your website:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-XXXXXX-X");
pageTracker._addOrganic("bing.com", "q");
pageTracker._trackPageview();
} catch(err) {}</script>

The new line of code that you should see is the _addOrganic call:

pageTracker._addOrganic("bing.com", "q");

There are two parts to the _addOrganic call – the first part (where it says “bing.com”) is the search engine domain name. The second part (where it says “q”) is the query parameter that displays the search term in the URL of your browser’s address bar.

The domain name is easy to get – simply grab your favorite site’s URL, remove the “www” prefix, and you have a domain name! The query parameter part may be tricky, depending on how your favorite website works. For example, on Bing.com, a search for “guitar hero accessories” returns this URL:

http://www.bing.com/search?q=guitar+hero+accessories&go=&form=QBLH

See the “q” right before my search term, behind the = symbol? Entering in “q” in the _addOrganic function will tell Google Analytics to look for “?q=” and a search term after the = symbol, so that you can get search term information from your new organic source as well as having it counted as an organic search engine!

Just keep in mind that not every website will have easy to find query parameters like the one from Bing.com does, and some websites will use something other than the letter “q”. For example, AOL.com uses “query”, and they use a different structure than Bing.com:

http://search.aol.com/aol/search?s_it=comsearch40&query=xbox+360&do=Search

When using _addOrganic, make sure to update the Google Analytics Tracking Code on EVERY PAGE of your website – if a person lands on a page that doesn’t contain the _addOrganic function, their traffic source will be counted as “referral”, not “organic”, so it’s vital to update this on all of your website’s pages, not just your homepage.

Hope you found this useful! Next time I will talk about how to modify your Google Analytics Tracking Code to treat certain keywords or referring websites as “direct” traffic. Stay Tuned!

© 2017 MoreVisibility. All rights reserved