“Show me the money!”
Cuba Gooding Jr. certainly understood the power of seeing the money in black and white. Anyone running an ecommerce site should be just as excited to see the money in reporting tools such as Google Analytics. Not only can overall revenue be measured in Google Analytics, but that revenue can be viewed for different segments such as sources, mediums, new or returning visitors, etc.
By using custom variables, it is possible to get an even more granular breakdown of ecommerce data than what Google Analytics offers by default. Although these custom variables can be very powerful, certain pitfalls should be avoided if you are also using ecommerce tracking. For a good introduction to custom variable implementation, see Caitlin Cook’s article here.
Use Case for Advanced Implementation of Custom Variables for E-commerce Attribution
Recently, I implemented custom variables to break down revenue by customer types for one of our PPC clients. For this particular client, there was a dealer sign-in, which indicated a different type of customer. With a careful installation of custom variables and ecommerce code, the client is able to see ecommerce data for their dealer customers.
Continue reading to find out how to set this up correctly and to see a sample report.
Custom Variable Recap
Before getting to the implementation, it bears talking a bit more in depth about custom variables. On any given page, you can set a maximum of five different variables. There are three different scopes for each one that you set. The broadest scope that can be set is visitor level. At this level, the variable will last multiple sessions until overwritten or deleted. The next scope is session level, which lasts the duration of one visit. The narrowest scope is page level, which only applies to a single pageview. With this in mind, let’s take a look at installation:
Tracking code needs to be placed on the dealer sign-in page to set the custom variable. NOTE: E-commerce data will only be associated with a custom variable if its scope is set to session or visitor level. For our example, the scope is set to ‘2’, which is session level. Depending on whether you are using asynchronous or traditional syntax, your code should look similar to one of these examples:
The ecommerce instructions from Google (found here ) show the code typically needed for an ecommerce installation. NOTE: If you need to set a custom variable on this page, you need to do it before the pageview is tracked. Depending on whether you are using asynchronous or traditional code, the completed ecommerce code should look similar to one of the two example codes below (with the parts in yellow indicating the custom variable code).
When all is set up correctly, expect a custom variable report similar to this:
You might notice on the report that dealer and regular customer types both appear as values. Getting this extra level of detail requires a little more logic built into the custom variables, and with a little care can be extended to even more granular customer segments.
So just to recap, in order to make sure ecommerce is properly reported within Google Analytics, you must make sure of the following:
1. The custom variable must be set at either the visitor or session level (1 or 2).
2. The custom variable must be set before the ecommerce code is called.
Have you used custom variables in an interesting way? Tell us how by leaving a comment!