The Power of Multiple Custom Variables
June 11th, 2010 | Published in Google Analytics
This is the first part of a two part deep dive guest post about using Multiple Custom Variables written by Allaedin Ezzedin from E-Nor, a Google Analytics Certified Partner in Northern California.
This time of year is the perfect time for a deep-dive analysis of your online business. Summer is about to get under way, and the school year and holidays are a ways off. Equipped with the "Google Analytics more Powerful, Flexible and Intelligent" feature set, we are now able to extract insights that weren't available to us in the past, and go beyond the out-of-the-box reports and segmentations. We'll take a deep dive below, and you can also read more in the help center here.
One of the most amazing features made available in the October 20, 2009 announcement was Multiple Custom Variables (MCV). Google calls it "MCV" and I call it "Google’s gift to humanity". Prior to the MCV announcement, we were limited to tagging visitors by a single variable (SetVar) based on their interactions with a site. With the new MCV feature we can now track visitors according to any number of interactions and behaviors on the site.
In this post, I will walk you through a practical example that I hope you can apply to your own business.Say you have an online store where you sell clothes for men, women and kids. You (and your boss) are not satisfied with aggregate data, so you go to your friendly marketing manager and web analyst and ask them to segment and segment deep! What you really want is to have more visibility into the shopping experience based on:
- products and departments of interest
-
- departments: men, women, etc.
- categories: athletic, suits, shirts, etc.
- special sections: wedding registry, wish list, etc.
- buyers & non-buyers
- site language selection: English, Spanish, etc.
Your request shall be answered using the powers of MCV! Here is a brief illustration of how it works.
What does "Multiple Custom Variables" do?
The Multiple Custom Variables feature allows us to label visitors at three levels, "visitor", "session" and "page". Note: none of the data from MCV personally identifies a visitor - these are totally anonymous labels.1. Visitor-level Labels
These labels are permanent and will stay attached to the visitor for the current and future visits as long as the visitor's cookies are not cleared and the specific label is not overwritten by another label.
2. Session-level Labels
These labels stay attached with the visitor as long as the visitor is active on the site. Once the visitor leaves the site or the session expires, the labels will disappear.
3. Page-level Labels
Visitors can be assigned to labels at the page level if they interact with certain events (flash, video, Ajax...) or view certain pages.
Now, let's go back to our online store example and walk through our implementation strategy and technical details.
The Strategy
As visitors enter the store website, they will be tagged with different labels based on the pages they visit (products and store departments):
Example 1:
Tom is an English-speaking visitor, viewed a product (women pajamas), added the item to the shopping cart and then completed the purchase transaction.
At the end of the session, Tom’s visit will be labeled as the following:
Example 2:
Sara is a Spanish-speaking visitor, viewed a few products (men and women apparels), and then left the site without buying.
Sara is a Spanish-speaking visitor, viewed a few products (men and women apparels), and then left the site without buying.
At the end of the session, Sara’s visit will be labeled as following:
The How
1. Customizing the tracking code:
Visitor-level Labels
At the visitor level we will use custom variables to segment visits based on the site interface language selection. This custom variable will stay attached to the visitors for future visits starting from the visit in which they selected the interface language (until they clear their cookies).Setting the value of "interface-language":
Visitors are assigned to the language segment according to their selection in the language form.
Add custom code to the form onSubmit event as illustrated below:
Session-level Labels
At the session level we will use custom variables to distinguish visitors’ behavior across sessions based on their conversion. In this way, we can segment visits by those who complete ecommerce transactions versus those who just browse products in the site.
A visitor will be tagged as a "buyer" if he or she completes a transaction.
Setting the value of "visitor-type" to "buyer":
In the transaction confirmation page (thank you page) add the following code inside the Google Analytics Tracking Code (GATC) right before the pageview GIF request _trackPageview()
pageTracker._setCustomVar(2, "visitor-type", "Buyer", 2);
If it is not possible to add the custom code inside the GATC, then add the following code after the GATC:
Page-level Labels
At the page level we will use custom variables to determine which products' categories and store departments are more visited. We will set a custom variable at the page level for each product, where the product category and the department for that product is set as a custom variable.
Setting the value of "store-department" and "product-category":
In each product page, add the following code inside the GATC right before the pageview GIF request _trackPageview()
pageTracker._setCustomVar(3, "store-department", “Men", 3);
pageTracker._setCustomVar(4, "product-category", "Suits", 3);
Visitors will be tagged based on their gift card and registry selections.
www.domain.com/baby-registry.html
www.domain.com/wedding-registry.html
www.domain.com/wish-list.html
www.domain.com/wedding-registry.html
Enough coding! You should now be equipped to create and use MCV. Next post, we'll take another slant and show you how to create custom segments using the values you've designated in your MCV.