Click To Redirect

Pages

Art: Creating and implementing Custom Dimensions

If this is the first time that you are reading anything about custom dimensions, I would recommend you all to read the earlier article which explains a bit about custom dimensions and metrics by clicking on the link



Now that you have a basic idea about what custom dimensions are, and why do we need them in the first place, let's talk about how to create them. Like all other implementation tips, this one also starts by logging into your GA account. Now go to Admin section and look within the property hierarchy (Information about GA Hierarchies) and find custom definitions.



1) Custom Dimensions: Click on custom dimension to create your first custom variable within GA account. You will notice New Custom Dimension on the top, as shown in the image below:


Click on that and go to the next page where you will have to name your goal, and choose one of the four scopes:

a) Hit
b) Session
c) User
d) Product


--------------------------------------------------------------------------------------------------------------------------
Detour: Before we proceed any further, we need to understand the the meaning of scope, and the 4 types that are provided by GA.

Scope: Consider scope as boundary, the limit of the variable that we are creating will last for the scope that we define. That is to say that the value of the variable will persist till the point of scope. If you are familiar with Adobe Analytics, think of it as evar, and you define expiration of that particular evar in scope.

For those who don't, keep reading. Think of an example below:

I declare a variable at Page A, and now I go to Page B, what should happen to this variable? Should it lose it's value? Should it carry forward it's value? Or should it have a new value? If I want a variable to reset after every hit, then I can put the scope as hit.

I hope this clears the concept of Scope, now let's tlak about different types of scopes:

a) Hit: If I want a variable to reset after every image request (Understand image request from here) then I can use the scope as hit. It would practically mean that after ever hit, your variable would be initialized to NULL all over again. Some of the best candidates for this kind of variable are error message, page name etc

b) Session: If you want a variable to persist for the entire session (what is session? Read here) then you can keep the scope as session. What it also means is that if you trigger a custom dimension A with value 'X' with scope session at 3rd hit, then previous 2 hits, where custom dimension A was not even triggered, would also be having value 'X' and at the same time, all future hits will have A initialized as 'X'.

Now suppose you again click on a page at your 10th hit where custom dimension A gets the value 'Y', then all previous hits will also get the value of A as 'Y', even at places where it was marked as 'X'.

Think of a banner displayed on a home page, for 10% discount, now you need to track the effectiveness of this banner. The best way to do it would be to set up a custom dimension 'Discount', and when someone clicks on the banner, initialize the variable 'Discount' as '10% Offer'.

Now the visitor traverses your website, and on tenth page, Page J, he clicks on another discount banner for 15% discount, so you would want to overwrite the value of 'Discount' variable with '15% Offer'. This is exactly what scope does. Now if our visitor purchases something, this purchase would be credited to '15% Offer', thereby giving you an idea of what works better on your website.

Some of the best candidates could be, discount coupon code, email address etc

c) User: This would mean that the value of the variable will be bounded to the visitor, or user here, with the cookie  (what is visitor? Read here). So, this would mean that the value of the varibale would persist till the time GA cookie last in the visitor's system,

As an example, think about a visitor, who goes through 5 pages of your website in his session 1, without triggering any custom dimension. In session 2, on 5th Page he triggers custom dimension 1, with value X. Then automatically all hits of session 2 will get the value X, much like when scope is session.

The difference would be when the user comes on session 3, then even on the first page of visit, he would automatically have X initialized for custom dimension 1 for the entire session/visit, unless visitor again trigger this custom dimension with some other value.

This kind of scope can come in real handy to gauge the prolonged effect of certain campaigns, especially email, social media, or back to school campaigns.

d) Product: Here the value of the custom dimension is bonded with the product, rather than the visitor/visit related information. Think about product discount offers, there can be 3 products with different discounts, and all those can be tracked by same 'Discount' custom dimension. Each product will have it's own value and hence making it easier in reporting to figure out what discount/offer works best with which product.

Best examples of such variables could be, category of customer (premier, economical, value for money), offers etc.
--------------------------------------------------------------------------------------------------------------------------

After selecting the scope, all you would have to do is, click create to get the code for the custom dimension as below



Now comes the question of where to place this code. You would need to place this code just below the line:

ga('create', 'UA-XXXX-Y', 'auto');

But just above the line 

ga('send', 'pageview');

This way we will create the custom dimension just after the GA tracker is created, and then will send it with the pageview hit to the GA servers.

2) Custom Metric: These can be created by following pretty much similar approach as we did while creating custom dimensions. We would need to click on custom metrics, then on new custom metric to create one. Once we do that, GA would require us to provide name and scope of the metric, pretty much the same way as custom dimension. Only differences would be that this time you might put a maximum and minimum value of the metric. For example, if you would want to count how many times visitors subscribes on newsletters, there for every visit, you might keep the value maximum of 1.

In addition of maximum and minimum you will also have to select the type, where you can either classify it as time, currency or integer, thereby displaying the value in your reports in a format that would be easier to understand for analysts. 

In free version of GA you will get 20 custom dimensions and 20 custom variables, whereas in GA premium you would be provided with 200 custom dimensions and 200 custom metrics. You can't remove/delete custom definitions, though you can deactivate them, or re-use them. But in case of re-use, it becomes really difficult to filter out the old values. So use these very judiciously. 

I feel that these custom definitions are most powerful, important and complex concepts of GA, so I would recommend you all to re-read the article if you face any issues. Also, you can go to the GA developer page by clicking here to read more about it.