|Smart analyst, smart analyst, what do you see?
I see more segmentations made just for me!
Marketer, marketer, what do you see?
Business owner, business owner, what do you see?
Online shopper, online shopper, what do you see?
Say you have an online store where you sell clothes for men, women, and children. Wouldn’t it be nice to have more visibility into the shopping experience based on site visitors’ age, gender, and products of interest?
Say Hello to a feature known as “Multiple Custom Variables!” To read more about how it works, check this post in the Google Analytics blog.
In this post, I would like to walk through our implementation strategy and technical details.
As visitors enter the store website, they will be tagged with different labels based on some personal unidentifiable information (gender and age), and based on the pages they visit (products and store departments):
Tom is a new visitor. He registered on the site, viewed a product (women’s pajamas), added the item to the shopping cart and then completed the purchase.
At the end of the session, Tom’s visit will be labeled as the following:
Sara is a returning visitor who in a previous visit registered to the site. She viewed a few products (men’s and women’s apparel), and then left the site.
At the end of the session, Sara’s visit will be labeled as the following:
1. Customizing the tracking code:
At the visitor level we will use custom variables to segment visits based on their entries in a form. Let’s use the values that visitors voluntarily enter in the “gender” and “age” fields in the following form. These custom variables will remain attached to the visitors for future visits starting from the visit in which they filled the registration form (until they clear their cookies).
Setting the value of “gender” and “age”:
- Add custom code that takes the gender and age values from the registration form.
- Pass the two variables (gender-variable, age-variable) to the registration confirmation page
- In the registration confirmation page, add the following code inside the GATC right before* the pageview GIF request _trackPageview()
* If it is not possible to add the custom code inside the GATC, then add the following code after the GATC
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 e-commerce transactions versus those who just browse products on the site.
A visitor will be tagged as a “buyer” if he or she completes a transaction. If they do not buy anything, the visitor will be tagged as “justlooking”.
Setting the value of “visitor-type” to “buyer”:
In the transaction confirmation page (thank you page) add the following code inside the GATC right before the pageview GIF request _trackPageview()
Setting the default value of “visitor-type” to “justlooking”:
All visitors will be tagged by default as “justlooking” once they enter the site by setting the value of the custom variable “visitor-type” to “justlooking” at the session-level.
Add the below code* to all landing pages right after the GATC.
* High-level description of the code:
- extracts the “_utmb” string from the cookies set by Google Analytics
- extracts the “pageview count” value from the _utmb cookie
- if the session’s “pageview count” is equal to 1 (landing page), set the value of “visitor-type” to “justlooking”
At the page level we will use custom variables to determine which product categories and store departments are 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()
2. Creating Custom Advanced Segmentation
Enough coding!! Now it is time to create some custom segments we can use for deep analysis.
In this section, we will set up a simple custom segment for all ladies (31 to 50 years’ old) who visited the men’s department, looked at suits, and bought an item during their visit.
- Sign in to your Google Analytics account
- Advanced Segments > Create a new advanced segment
- Add the following dimensions:
3. Viewing Reports
We are now ready to analyze based on custom segments built upon our custom variables! Let’s look at the amazing data available in our new segments:
Segment 1: Male shoppers (31 to 50 years’ old) who visited the women’s department, looked at Suits and bought an item during their visit
Segment 2: Female shoppers (31 to 50 years’ old) who visited the men’s department, looked at Suits and bought an item during their visit
From the first glimpse at the dashboard numbers above, we can confirm that for the 31 to 50 age group:
- It takes men fewer number of page (around 3 pages on average) to buy suits for women compared to women shoppers who visit 5 pages on average to make a suit purchase for men.
- The number of women who shop for men is more than the number of men who shop for women! Shame on us men .
If you came up with more interesting segments please share with us, we are very interested hearing from you.