• Home
  • Google Analytics
    • Customizations
    • For Ecommerce
  • Speaking
  • About
    • About Me
    • Contact Me
    • Disclaimer and Privacy Policy

Analytics Talk

Digital Analytics for Business

You are here: Home / Analysis / 5 Google Analytics Custom Variables for Ecommerce

5 Google Analytics Custom Variables for Ecommerce

Posted: June 14, 2011 38 Comments

I believe that every business can use Google Analytics custom variables. Especially ecommerce businesses. Custom variables inject new data dimensions that are crucial for segmentation. As analysts we need to do segmentation to understand user behavior. And ecommerce sites have certain unique behaviors that are not tracked with a basic Google Analytics implementation.

For those that have not used custom variables before you can get read Mastering Custom Variables for overview.

Now on to the custom variables!

Tracking Coupon Codes and Promotional Codes
Tracking Coupon Codes with Google Analytics
I think this is a pretty obvious use of custom variables. If you sell something you probably run various promotions. And you need to track these promotions to see how they perform. Some promotions can be tracked using campaign tracking. I’ve seen lots of people use the utm_content parameter to identify the promotion in a marketing campaign, like an email. But a custom variable works just as well.

When coming up with a strategy think about how you might scale this as time goes on. Do you want all of your promotional codes aggregated together under one variable? You could do something like this:


_gaq.push(['_setCustomVar',1,'PromoCode','',3]);

Or you could get fancy and use different custom variables to bucket groups of promotions, like seasonal promotions. For example, if you lots of promotions during the holiday season you might want to create a custom variable named HolidayPromos and then a unique name for each of the codes, something like this:


_gaq.push(['_setCustomVar',1,'HolidayPromo','Free2DayShip',3]);
_gaq.push(['_setCustomVar',1,'HolidayPromo','FreeWrapping',3]);
_gaq.push(['_setCustomVar',1,'HolidayPromo','10perOff',3]);

The above code would need to appear on your receipt page. And remember, the slot, or index, in the code above may be different for you. It all depends on your use of custom variables.

You might be wondering why I decided to go with a page level custom variable here. Remember, Google Analytics will sessionize a page level custom variable. So even though the custom var will only fire on the receipt page the data will be applied to the entire visit.

Tracking Payment Method

Remember, we study visitor behavior to understand the impact on business. One of these behaviors is how people pay for a purchase. Is there a difference between a visitor who pays with a credit card vs one who pays with PayPal? Does one spend more, on average, than the other? You’ll never know unless you capture payment type and review metrics like average order value and conversion rate.

To capture payment type use a page level custom variable. The resulting GA code will look something like this:

_gaq.push(['_setCustomVar',2, 'PaymentType','',3]);

Don’t forget to replace with the customer’s payment method.

Tracking Shipping Method

Why not tracking shipping method with Google Analytics?
Like payment method, it’s interesting to see what shipping method people choose with various products. Why? Perhaps people who buy certain products choose certain types of shipping. If so, maybe you can build a new promotion using this information. Could there be no insights here? ABSOLUTELY! But you’ll never know unless you have some data and do a bit of analysis.

_gaq.push(['_setCustomVar',3,'CustType','Repeat',1]);

Tracking Repeat Customers

I remember reading Eric Peterson’s book Web Analytics Demystified a looong time ago. Besides being one of the first books on analytics it was exceedingly actionable. One of the ecommerce key performance indicators Eric talked about, and rightfully so, was the repeat-buyers.

The behavior of repeat customers is different than first time customers. This segment of customers usually takes less time to purchase due to a knowledge of your products and services. Normally it costs you less money to get these people to convert. So it’s a good idea to understand what marketing they respond to and how they use your website.

To track repeat customers in Google Analytics you must use a visitor scope custom variable. Remember a visitor scoped custom variable persists on the visitor’s computer as a cookie. The trick is when you set the custom variable.

Most people think you can set the custom variable when the transaction happens, like this:

_gaq.push(['_setCustomVar',4,'CustType','Repeat',1]);

But in reality this will not work. When you set a visit level custom variable the value gets applied to the CURRENT visit and all future visits. So you need to wait until the SECOND purchase before setting the above custom variable. Then it should work just fine.

[UPDATE: Elizabeth Brings up a good point in the comments. This method will only work if the visitor comes back and makes a second purchase on the site. You can tweak the above logic and set the custom variable on the visitor’s return to the website, rather than when they make a second purchase. While this is not perfect it is a workaround.]

I should note that this is an AWESOME custom variable to use in an advanced segment. Actually, they’re all great to use in Advanced segments, but segmenting repeat buyers is especially useful

Creating a customer segment in Google Analytics

Purchase History

This is where things get a little more complicated. Tracking things like purchase history requires a bit of configuration on the server side, meaning you or your nerds need to create some code to categorize customers based on the number of purchases they’ve made in the past. Rather than track every single purchase I prefer to bucket the purchases, like this:

  • 1 to 3 purchases
  • 4 to 6 purchases
  • 7 + purchases

You need to have the logic on the server to review the custom’er purchase history and set the custom variable accordingly. The GA JavaScript will look something like this:

_gaq.push(['_setCustomVar',5,'PurchHistory','1-3',1]);

Now you’re probably thinking that there is some duplication with the previous custom variable, and you’re right. The repeat customer variable is a bit more generic and gives you a quick view of new and returning customers. The purchase history variable is geared towards deeper analysis of customer behavior.

So there you have it, five custom variables for ecommerce websites. This is by no means an exhaustive list, but I think these can help any commerce based business to better segmentation and analysis.

Are you using custom variables on your ecommerce website? If so I’d love to hear how!

Filed Under: Analysis, Ecommerce, Tracking Tagged With: custom variables, ecommerce, Tips, tricks

Comments

  1. Phil Pearce [PPC_Guru] says

    June 14, 2011 at 1:19 am

    Hi Justin,

    Useful Article. It will be even more useful when more than 5 CustomVars are available ;)

    Regarding “Tracking Repeat Customers”…

    Do you have an example of the php serverside code used to set the repeat customer?
    [e.g. GroupBy CustomerID where count(Transactions) >=2 ]

    Many Thanks

    Phil

    Note: if scope is left empty it defaults to visit-level
    [‘_setCustomVar’,4,’CustType’,’Repeat’]

    Reply
    • Justin Cutroni says

      June 14, 2011 at 7:53 am

      @Phil: I agree, having more custom variables will be helpful. I tried to use mostly page level custom vars to minimize the impact on an implementation, but sometimes it’s hard to keep it to 5 custom vars. Most of my clients do the server side coding, and my PHP skills are rusty! Let me see if I can get one of our guys to bang something out. (And thanks for the edits!)

      Reply
  2. Soeren Sprogoe says

    June 14, 2011 at 4:02 am

    Sweet little GA ninja tricks!

    Funny, I did a post (in Danish) just last week about tracking repeat customers:
    http://www.afdeling18.dk/blog/2011/6/3/ga-tricks-skaffer-mine-kampagner-nye-eller-gamle-kunder.aspx
    (Sorry for the plug, feel free to remove it if you’d like)

    But instead of custom vars I usually choose to use the “Affiliation” field of the eCommerce tracking code instead. Mostly because it’s at that point in time in your backend code that you’ve got the customer details anyways, so you can figure out whether it’s a repeat customer or not.

    Anyways, being able to track repeat customers in Google Analytics does wonders with your Google Adwords campaigns, as you’re then able to better grasp customer lifetime value (or cost rather) and take your campaigns to the max.

    Reply
    • Justin Cutroni says

      June 14, 2011 at 7:56 am

      @Soren: Thanks so much for the link to your post! While I don’t know exactly what you wrote I’m more than happy to leave it up.

      Using the Affiliation field to track repeat buyers is a good idea. The reason I chose to use a custom variable is:

      1. Ecommerce dimensions can not always be combined with click-related metrics in a custom report.

      2. The Affiliate field does not persist across multiple visits. So while it does provide data about the purchase behavior it does not help us understand cross-session browsing behavior.

      Thanks for the link and comment.

      Reply
  3. Peter O'Neill says

    June 14, 2011 at 4:23 am

    Great suggestions Justin, have added to my list of standard custom variables for ecommerce clients.

    Can I also suggest:
    * On the Product Details page
    – Availability (proportion of sizes/colours available)
    – Brand
    – Price Range (group into buckets so low, medium, high)
    – Sale (flag if at a reduced price)
    * On the Search Results page
    – Number of search results

    Reply
    • Justin Cutroni says

      June 14, 2011 at 7:58 am

      @Peter: Great suggestions Peter, thanks for adding them here. As a note, I would add most of those a page-level variables or perhaps even events, especially if I’m using all 5 custom variables.

      Reply
  4. Elizabeth Brady says

    June 14, 2011 at 9:16 am

    Thanks Justin — I am interested in the repeat customer custom variable. I previously implemented it as a visitor-level custom variable, because I think the original Google Analytics documentation said it would apply to future visits only, rather than the current visit, but as you point out I was frustrated to notice that it actually applies to the current visit as well. I would love to be able to identify a return visitor as a prior customer, to compare their visit conversion rates to other visitors. Your solution will only identify them when they purchase the second time (so it will be a 100% conversion for that visit) — do you know any solution for tracking ALL return visits for prior customers and excluding the visit of that first purchase?

    Reply
    • Justin Cutroni says

      June 14, 2011 at 7:00 pm

      @Elizabeth: You make a fantastic point. I’ve updated the post to include info that aligns more with your comment. It’s probably better to bucket a customer on the following visit, not purchase. In all honesty, OMTR is way better at this than GA. They’re able to draw a clear line in the sand when a visitor moves from one custom segment to another.

      Reply
  5. Koozai Mike says

    June 16, 2011 at 3:35 am

    Excellent tips. Custom variables are something we are playing with and it’s an area that most Analytics users don’t even know exist. Track everything, should be the Google Analytics motto.

    Reply
  6. Will Reinhardt says

    June 22, 2011 at 11:55 am

    Just to clarify Phil’s note at the beginning, if scope is left blank it defaults to page level, not visitor level. More on that here: Custom Variables.

    Reply
  7. Shane Revax says

    November 9, 2011 at 11:20 am

    Cutroni has just written an excellent post on five Google Analytics custom variables that ecommerce companies should definitely use. – We vouch for that, great post.

    Reply
  8. Gautier Lemesle says

    December 8, 2011 at 2:48 pm

    Great article Justin :)

    Though I didn’t already applied this to our current implementation, one thing came to my mind.

    In the case of custom variables used for ecommerce, most of the people would probably like to get ecommerce data to be attached to custom var reports (Audience => Demographics => Custom Variables) to get a revenue perspective of their custom variables.
    Problem is that using Custom Variables with Page level scope (3), eCommerce data won’t get parsed to the custom var inside those reports.
    So, as you mention that Google Analytics will sessionize a page level custom variable, you might want to apply a Session level scope (2) to custom var used in eCommerce context to be able to see eCommerce data for each custom var.

    Reply
  9. Charmis says

    December 21, 2011 at 5:30 am

    Hello,
    i have a small site mentioned above i have created a payment hub called as mypaymenthub.com for the mentioned website, there i have page where user registers and fills the form on that page,
    I wanted a goal that shows me the visitors from my site to the register page on the my payment hub
    can anyone please help me with the query.

    Thanks,
    Charmis

    Reply
    • Justin Cutroni says

      February 14, 2012 at 4:32 pm

      @ Charmis – I’m assuming that everything is on the same domain. If so, then you should be able to create a goal (specifically a URL destination goal) for the registration page. If your payment hub is NOT on the same domain then you need to look into cross domain tracking. And if you don’t control the code on the payment hub then you need to work with the payment hub provider to get things working. Cross domain tracking can be really messy.

      Hope that helps.

      Reply
  10. zoltan petrasovits says

    January 22, 2012 at 12:31 am

    Webmasters usually me know the detailed settings. Those who claim to know too lazy. Those who have used them you are reading now! :)

    Reply
  11. Thiago says

    February 2, 2012 at 9:49 am

    Justin,

    We recently added a page-level custom variable to our site to track “Content Groups” (which is a pretty standard CV implementation). We were surprised, however, to see that the page-level CVs do not have any revenue metrics attached to them.

    How would you go about creating a revenue breakdown of the areas of your site (Content Groups) using CV? I thought that the page-level CV would certainly retain the revenue aspect, if that visitor checks out, but it’s not that way for us.

    Thanks for your input,

    -T

    Reply
    • Justin Cutroni says

      February 14, 2012 at 4:29 pm

      @ Thiago – All of the ecommerce metrics should be compatible with a page level custom variable. Are you just looking at the Ecommerce tab in the Custom Variable reports or are you trying a Custom Report of the API?

      Reply
  12. DavidG says

    August 2, 2012 at 4:38 pm

    Justin,

    Great article. I know this is old, so not sure if I will receive a response, but here goes.

    Your repeat customer custom variable brought up another piece of information I am wanting. We run PPC campaigns and some of those campaigns are geared to be introducers/informers rather closers. So I want to see if visitors are making return visits after a visit (preferably their first) from one of those campaigns. I figured you would need to use a visitor level CV, but not positive. Or how the advanced segment would look.

    Any insight?

    Thanks.

    Reply
    • Justin Cutroni says

      September 6, 2012 at 8:22 pm

      @DavidG: Yes, you would need to use a visitor-scoped custom variable to identify people coming from those PPC campaigns. But what about using the Multi-channel funnels report? If the visitor converts then you’ll see that campaign/adgroup/keywords in the MCF reports.

      Reply
      • DavidG says

        September 10, 2012 at 1:55 pm

        Thanks for the response Justin. I did consider it, but the MCF reports only look back 30 days, right? Our buying window often is longer. Plus, having it as a CV would allow me to apply other advanced segments to it.. Where, as far as I can tell, I can’t do that in the MCF.

        Thanks again.

        Reply
  13. Ramos says

    February 4, 2013 at 5:10 pm

    Hello,
    Is it possible to add a coupon code at order level and/or order-product level?

    What i need to do, if possible, is to generate a report where i can see the something like this:
    For An Order:
    Product | Quantity | Unit Price | Promo Code | Revenue

    Obviously the revenue has to have the (UnitPrice * Quantity) – (CouponDiscount)

    Hope you can help me out with this. Thanks!

    Reply
    • Justin Cutroni says

      February 19, 2013 at 10:48 pm

      @Ramos: Unfortunately no, there is no simple way to do that. You can hack this. The easiest way is to create a secondary product line foe each coupon/product combination. That would be the only way to create a product-specific coupon. The coupon “product” could have a negative value to subtract the correct amount from the total transaction value.

      That’s about it. There really is no easy way to do this.

      Great question, thanks for asking.

      Reply
  14. Matt Browne says

    February 6, 2013 at 7:17 pm

    Thank you for the informative post about CV for ecommerce sites. I’m about to implement CVs for a site I manage and I read the news about Universal Analytics. I wanted to know if we no longer needed a CV for repeat customers given that would be a tracking metric that would now be available to us. Is that correct?

    Thank you,
    Matt

    Reply
    • Justin Cutroni says

      February 19, 2013 at 11:07 pm

      @Matt: Once we get true user segmentation you will no longer need to use a custom variable (or custom dimension in the new Universal Analytics) to track repeat customers. I should point out that user segmentation is a separate feature from Universal Analytics.

      Hope that helps.

      Reply

Trackbacks

  1. What’s the deal? More thoughts on deal sites for customer acquisition says:
    June 14, 2011 at 4:19 pm

    […] can do the same with your web traffic, too. Justin Cutroni offers a handy look at using Google Analytics custom variables for e-commerce that you should check out/forward to your […]

    Reply
  2. 5 Google Analytics Custom Variables for Ecommerce – Analytics Talk | SFWEBDESIGN.com says:
    June 14, 2011 at 7:13 pm

    […] The rest is here:  5 Google Analytics Custom Variables for Ecommerce – Analytics Talk […]

    Reply
  3. Tracking Repeat Customers in Google Analytics says:
    June 15, 2011 at 11:38 am

    […] Cutroni has just written an excellent post on five Google Analytics custom variables that ecommerce companies should definitely use.  Actually the principles behind these variables apply to all web analytics tools, just the type […]

    Reply
  4. SEO, SEM, Social Media y Marketing 3 | SEOcretos says:
    June 17, 2011 at 1:54 am

    […] 5 Google Analytics Custom Variables for Ecommerce. vía: Analytics talk […]

    Reply
  5. When Custom Variables Are Consistently Useful: Customer segmentation by membership | Zimana Web Analytics Blog says:
    January 11, 2012 at 5:24 am

    […] There are plenty of other ways a custom variable can be used. Justin Cutroni offers a unique way of using custom variables for coupons – you can read about his process here. […]

    Reply
  6. Mesurer le ROI des réseaux sociaux avec Google Analytics « pratiquesweb says:
    January 15, 2012 at 1:03 pm

    […] Cutroni, qui vient d’ailleurs de rejoindre Google, explique aussi, par exemple, comment tracker les clients qui effectuent un nouvel achat sur le même site. Les possibilités sont donc particulièrement […]

    Reply
  7. What is the benefit of custom variable and how can we customize it? - Quora says:
    January 31, 2012 at 12:37 am

    […] like detailing the use of custom variables for tracking shipping preferences to repeat customers.http://cutroni.wpengine.com/2011/06/…Hope this helps, MarcThis answer .Please specify the necessary improvements. Edit Link Text […]

    Reply
  8. Google Analytics : 5 astuces SEO et e-commerce « pratiquesweb says:
    April 3, 2012 at 11:39 am

    […] Justin Cutroni, qui a rejoint l’équipe de Google Analytics il y a peu, a publié il y a quelques mois une série de codes de suivi pour mettre en place des indicateurs très […]

    Reply
  9. Google Analytics Custom Variables for Publishers - Analytics Talk says:
    September 12, 2012 at 9:27 am

    […] for Publishers Posted: September 12, 2012 Leave a Comment Tweet In the past I wrote about 5 Google Analytics custom segments for ecommerce, so it only makes sense that I return the favor for […]

    Reply
  10. How to Track Offline Marketing Campaigns with Analytics says:
    December 3, 2012 at 2:46 pm

    […] you’re familiar with using custom variables in Google Analytics, you can use this guide to get Google Analytics to track your coupon codes and promotional […]

    Reply
  11. How to Track Offline Marketing Campaigns With Analytics - SME World | SME World News, Blogs, Insights says:
    December 4, 2012 at 3:47 am

    […] you’re familiar with using custom variables in Google Analytics, you can use this guide to get Google Analytics to track your coupon codes and promotional […]

    Reply
  12. Online-Tracking von Offline-Kampagnen | Online Marketing News says:
    December 12, 2012 at 8:10 am

    […] Insbesondere in der Weihnachtszeit sind sie überall zu finden: Rabatt-Codes, die auf Offline-Werbemitteln angebracht werden, um bei einer Online-Bestellung Geld zu sparen. Gibt man den entsprechenden Code im Bestellverlauf ein, wird der Rabatt abgezogen und der Händler kann nachvollziehen, durch welches Werbemittel der Nutzer auf das Angebot aufmerksam wurde. Bei Analytics kann man hierzu eine spezielle Kampagne für Codes angelegt werden. Eine genaue Anleitung gibt es bei cutroni.com. […]

    Reply
  13. How to use Google Analytics to Track Printed Media Marketing Campaigns. | Showcase creativeShowcase creative says:
    June 3, 2013 at 5:18 pm

    […] Analytics Tracking – Google Analytics allows tracking of discount codes through custom variables. An excellent article by Justin Cutroni provides all the information you require. […]

    Reply
  14. Intro to Google Analytics Custom Variables | e-responsible! says:
    July 26, 2013 at 8:01 am

    […] 5 Google Analytics Custom Variables for Ecommerce […]

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

My Books

Google Analytics by Justin Cutroni
Learn More on Amazon.com

Performance Marketing co-authored by Justin Cutroni
Learn More on Amazon.com

Recent Posts

  • Understanding the Google Analytics Cohort Report
  • Using Offline and Online data to drive Google Analytics Remarketing
  • Understanding Cross Device Measurement and the User-ID
  • Universal Analytics: Now out of beta!
  • Advanced Content Tracking with Universal Analytics

Categories

  • About Google Analytics (25)
  • Analysis (52)
  • Analytics Strategy (3)
  • Campaign Tracking (14)
  • Ecommerce (8)
  • Event Tracking (10)
  • Remarketing (2)
  • Reporting (10)
  • Resources (7)
  • Tag Management (5)
  • Tips (25)
  • Tracking (52)
  • Uncategorized (64)
  • Universal Analytics (9)
  • Web Analytics (15)

Copyright © 2023 ·News Pro Theme · Genesis Framework by StudioPress · WordPress