Articles in The '_setVar' Tag


June 26 2009

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

by MoreVisibility

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.

January 28 2009

Why your Bounce Rate may start to go up from now on.

by MoreVisibility

Starting today, chances are that your Bounce Rate is going to go up, and your Time on Site metrics will start to become more realistic.

Should you panic and freak out? Should you hide under the bed and lock the door to your room? Should you pause all of your campaigns? Obviously, you shouldn’t do any of those things, but I should explain what’s going on before you reach a state of dementia.

Google Analytics has changed the classification of the setVar function – Custom Segments that appear in the Visitors >> User-Defined report. Previously, whenever a user reached a page that was making use of this setVar function within the Google Analytics Tracking Code, Google Analytics would consider that what they refer to as an “interaction hit”. Interaction hits, like Pageviews, Events, Transactions, and Experiments with Google Website Optimizer are what Google Analytics uses to calculate Bounce Rate and Average Time on Site.

So, for example, let’s say a visitor landed on a page of your website, but left without visiting any other pages. That is, as we all know and love, considered a Bounce. But, let’s say that that same page was using the setVar function. Before today, that visitor would NOT have been counted as a bounce, because Google Analytics would have fired off two “interaction hits” – one for the pageview on that landing page, and one for the custom segment caused by the usage of setVar. However, from here on out, a user that only views 1 page of your site and leaves will be counted as a Bounce, setVar function or no setVar function.

This also has an affect on your Average Time on Site metric. This is calculated by Google Analytics by taking the time stamp of when the first pageview on a website occurs, and subtracting that from the time stamp of your second pageview on a website. Now, if you don’t visit a second page and you bounce, Google Analytics cannot do the math, because it has nothing to subtract from, so it reports a 0:00:00 average time on site.

Previously, because of our setVar friend, Google Analytics would be able to do math, because it would have the time stamp of that first pageview, AND, the time stamp of the setVar function firing off. Since these happened so close together, you could easily see extremely low average time on site numbers, like a second or two. Clearly this was confusing and didn’t make sense, which is another reason why the good folks at Google Analytics have decided to make this change.

When should I use Custom Segments / setVar?

There are a few good places to use this function. One place is on the receipt / “Thank You” page that a user sees after they buy something from your store. This way you can identify anyone who reaches this page as a “shopper” or “customer” or as “awesome”, or anything that you want to call people who reach this page. Then, in your Visitors >> User-Defined report, you’ll be able to do some analysis on this segment of people.

You can also use Custom Segments / setVar based upon an option they select on a “Contact Us” or inquiry form. Let’s say your form has a question that asks users to select between: “Executive, Director, or Marketer”. You can use setVar here to identify people based upon their selection, and analyze the behavior of each custom group of people.

So don’t call your pay-per-click manager or SEO engineer and proclaim that the sky is falling – chances are very good that you will not notice too much of a difference, if at all. If you don’t use Custom Segments / setVar, then you have nothing to worry about. If you use setVar on multiple landing pages and in different places on your site, brace for impact because your Bounce Rate is going up. But hey, think of it like this: it’s for the better – this is now a much more accurate calculation – a truer representation of your real Bounce Rate and Time on Site metrics.

© 2019 MoreVisibility. All rights reserved.