Beginners Guide to Universal Analytics – Creating Custom Dimensions & Metrics

 

I have been using Universal Analytics (UA) for a while now and would like to share some quick tips to get you started.

The first thing that you need to understand is the difference between universal Analytics and Google Analytics.

 

Difference between Universal Analytics and Google Analytics

  1. Data Collection and integration
  2. Data Processing
  3. Custom Dimensions and metrics
  4. Custom variables
  5. User Interface
  6. Javascript library
  7. Tracking Code
  8. Technical Knowledge
  9. Referrals Processing
  10. Cookies
  11. Privacy and data usage

 

Data Collection and Integration

  • Universal Analytics (UA) provides more ways to collect and integrate different types of data than Google Analytics (GA).
  • Through UA you can integrate data across multiple devices and platforms. This is something which is not possible with GA.
  • Consequently UA provides better understanding of relationship between online and offline marketing channels that drive sales and conversions than GA.

 

Data processing

  • The date processing in UA is visitor based instead of visit based.
  • Consequently UA is more visitor centric than visit centric.

 

Custom Dimensions and Metrics

  • In UA you can create and use your own dimensions and metrics to collect the type of data GA does not automatically collect (like phone call data, CRM data etc).
  • These user defined dimensions and metrics are known as ‘custom dimensions’ and ‘custom metrics’.
  • Through custom dimensions you can import additional data into your analytics account.
  • GA does not allow you to define your own dimensions and metrics.

 

Custom Variables

  • UA uses custom dimensions instead of custom variables
  • GA uses custom variables instead of custom dimensions.
  • Though ‘custom dimensions’ are not available in GA, custom variables are still available in UA (although not sure for how long)

 

User Interface

  • Interface wise both UA and GA reports look the same.
  • The difference is in how each collect, integrate and process the data.
  • However once you start using custom dimensions and custom metrics, your UA reports may look very different from your GA reports.

 

JavaScript Library

  • UA uses ‘analytics.js’ JavaScript library whereas GA uses ‘ga.js’ JavaScript library.
  • The ‘analytic.js’ library is similar to ‘ga.js’ library but provides new set of features for collecting and integrating data.

 

Tracking Code 

UA uses different tracking code than GA:

gatc-example

uatc-example

 

Technical Knowledge

To use all the features of UA you need good technical knowledge of your development environment/ platform or you should know someone who has such knowledge.

Otherwise you may have a hard time using custom dimensions, custom metrics and integrating data across multiple devices/ platforms.

Without this technical knowledge, UA is not very useful  for you. This is not really the case with GA.

 

Referrals Processing

In UA referrals are processed differently.

By default all referrals trigger a new web session in UA. This can affect the total number of web sessions in your analytics reports.

For example: let us suppose a visitor arrived on the website www.abc.com from www.xyz.com then returned back to www.xyz.com.

When the visitor arrived on the website www.abc.com from www.xyz.com, it will trigger a new web session for abc.com website. When the visitor returned back to www.xyz.com from www.abc.com, it will trigger another new web session for xyz.com:

UA-refferals

If you do not want the new web session to be triggered when the visitor returned to www.xyz.com from www.abc.com then you need to exclude referrals from www.abc.com.

 

Cookies

Cookie is a text file which is used to store information about a visitor, his preferences, location, browsing behaviour and other details.

While GA can use up to 4 cookies (_utma,_utmb,_utmz and _utmv) to collect visitors’ usage data, UA uses only 1 cookie (called _ga).

Related article: Google Analytics & Universal Analytics Cookies – Complete Guide

 

Privacy and Data usage

Google warns against collecting any personally identifiable data in your UA accounts. Google can terminate your analytics account if you breach this policy.

You need to give your end users proper notice and get consent about what data you will collect via UA. You also need to give your end users the opportunity to ‘opt out’ from being tracked.

That means you need to make changes in your privacy and data usage policies. Google recommends using Google Analytics opt out browser add on if you want to block Google Analytics.

Note: You can learn more about the UA usage guidelines from here and about the privacy from here.

 

Server Side Configuration settings in Universal Analytics

UA lets you change following server side configuration sections via the account admin:

  1. Change session and campaigns timeout settings.
  2. Add/delete search engines
  3. Exclude referral traffic sources
  4. Exclude search terms

 

server configuration settings

In case of GA you need to add special tracking codes to all the web page on your website to change each of the aforesaid server side configurations.

UA has simplified changing these server configurations by providing easy to use controls in the account ‘admin panel’ which don’t require editing the existing tracking code on every web page of your website.

 

The Measurement Protocol

UA uses a new measurement protocol (a protocol is a set of rules) which let you send data from any device/system/environment (including smartphones, tablets, call center data, digital appliances, point of purchase systems or any online or offline customer contact point) to your Google Analytics account provided you have formatted your data according to the protocol.

Through this protocol you can import offline conversion data into GA. The measurement protocol includes a new JavaScript library called ‘analytics.js’.

Just like GA, Universal Analytics tracking code also request an invisible file called ‘_utm.gif’ each time a web page is loaded into the browser to send tracking data to the analytics server. This GIF request is pretty long and looks something like the one below:

http://www.google-analytics.com/__utm.gif?v=1&_v=j31d&a=883600465&t=pageview&_s=1&dl=http%3A%2F%2Fokdork.com%2F&ul=en-gb&de=UTF-8&dt=OkDork.com%20%7C%20Noah%20Kagan’s%20Blog%20About%20Marketing%20and%20More&sd=24-bit&sr=1600×900&vp=1583×330&je=1&fl=15.0%20r0&_u=MACAAAQBI~&jid=1551246513&cid=1701241469.1413716603&tid=UA-52269-5&_r=1&z=1412809081

Note: In case of UA the parameters of the _utm.gif are different than that of GA.

To learn more about the Measurement Protocol, check out the article: Understanding Universal Analytics Measurement Protocol

 

Setting up new Universal Analytics Account

Follow the steps below to set up your new Universal Analytics account:

Step-1: Get administrative access to your Google Analytics account.

Step-2: Go to ‘Admin’ area and from the property drop down menu, select ‘create new property’.

create new property

This will create a new ‘web property’ in your existing Google Analytics account.

Step-3:

new property

Select ‘Website’ under ‘What would you like to track?’. Enter your website name and website URL. Select your industry and reporting time zone as shown below:

new property2

Once you have completed the form, click on the ‘Get Tracking ID’ button.

Step-4:

universal analytics tracking code

The UA tracking code will now appear in a box. Copy-paste this tracking code in the head section (<head>….</head>) of every web page on your website. Remove the old Google Analytics tracking code at the same time.

Step-5: Check the source code of the home page and other web pages on your website and look for ‘analytics.js’. If you can see this JavaScript library in your HTML code then the website is using the UA tracking code. Also check your real time reports to make sure that you are getting data into your Universal Analytics reports.

Step-6: Change server side configuration options via your Admin panel (explained later in this article).

Step-7: Set up custom dimensions and custom metrics (if required).

 

Change session and campaigns timeout settings

session settings

Go to the ‘Admin’ area of your account and then click on ‘Session Settings’ link under ‘Tracking Info’ drop down menu.

session settings2

By default both GA and UA ends a web session after 30 minutes of inactivity on a website or when the browser window is closed.

By default the attribution to a marketing campaign expires (timeout) after 6 months from the last time a visitor visited your website.

There are certain situations in which you may need to change the default time when a web session or a marketing campaings ends.

For example:

1. If your website automatically logs out a visitor say after 2 minutes of inactivity (common in case of bank websites) or if visitors spend 5 minutes on an average on your website then it doesn’t make any sense to end a web session after 30 minutes of inactivity.

May be a session timeout of 5 minutes will be better in this case.

Choose a session timeout which matches to the average time spent on your website/web pages (verify this trend over a long period of time: at least 3 or more months).

Note: Your web session can not be less than 1 minute or greater than 4 hours.

 

2. Majority of marketing campaigns become irrelevant for conversion attribution after few weeks. So it doesn’t make any sense to set campaign timeout to 6 months.

Choose a campaign timeout which matches to the time you think your campaigns will remain relevant for attributing conversions.

Note: Your campaign timeout can not be greater than 24 months (2 years)

 

To change Session timeout in GA use _setSessionCookieTimeout() method. Similarly, to change Campaign timeout in GA use _setCampaignCookieTimeout() method.

Following is an example of how you can call these methods in your Google Analytics Tracking Code:

session-settings2

 

Customize Organic Search Sources

Google Analytics treats traffic from search engines not in the default search engine list as referral traffic.

So if you know a search engine (or may be your internal site search engine) which is not in this default list and you want Google to treat the traffic coming from it as ‘organic search traffic’ instead of ‘referral traffic’ then you need to add your search engine to the default list of search engines.

You can do this by going to the ‘Admin’ area of your account and then clicking on ‘Organic Search Sources’ link under ‘Tracking Info’ drop down menu:

organic search sources

add search engine

organic search sources2

Here I have added a search engine called ‘Duck Duck Go’ because it is not in the Google default search engine list. Now Google will treat all the traffic coming from DuckDuckgo.com as organic search traffic instead of referral traffic.

Once you have added other search engines, you can then see your search engine list like the one below:

add more search engines

  • You can click on ‘edit’ or ‘delete’ link to edit or delete your search engines.
  • You can also change the order of search engines in the list by dragging and dropping the order of each row.

Note: When you change the order of search engines in the list, it can affect how the data appears in your reports.

For example if you list abc.com first and search.abc.com second and both websites use the same query parameter say ‘s’ then all the searches that happened on search.abc.com will be attributed to abc.com. To change this attribution behavior you need to reorder the list in a way that search.abc.com appears first in the list.

If you want to add search engines in Google Analytics (instead of Universal Analytics) then you need to call the _addOrganic() method in your Google Analytics Tracking Code (GATC):

organic-search-sources4

 

Excluding Domains from your referral traffic

If you want to exclude certain domains from being labeled as referrer in your analytics reports then you can do this by going to the ‘Admin’ area of your account and then clicking on ‘Referral exclusion list’ link under ‘Tracking Info’ drop down menu:

referral exclusion list

exclude this domain

referral exclusion list2

 Here I am excluding the website eventeducation.com from appearing as a referrer domain in analytics reports.

If you want to exclude certain domains from appearing as referrers in Google Analytics reports (instead of Universal Analytics reports) then you need to call the _addIgnoredRef() method in Google Analytics Tracking Code of all the web pages on your website:

referral-exclusion3

 

Excluding Search terms from organic search traffic

If you want to exclude certain search terms from appearing in your organic search reports then you can do this by going to the ‘Admin’ area of your account and then clicking on the ‘Search Term exclusion list’ link under ‘Tracking Info’ drop down menu:

search terms exclusion list

exclude this search term

search terms exclusion list2

Here I am excluding the domain name ‘seotakeaways’ from appearing as organic keyword in my organic search reports.

Once this search term is excluded any traffic that comes from ‘seotakeaways’ search term will be treated as direct traffic by Google.

If you want to exclude certain search terms from appearing in your organic search reports in Google Analytics reports (instead of Universal Analytics reports) then you need to call the _addIgnoredOrganic() method in Google Analytics Tracking Code of all the web pages on your website:

search-terms-exclusion3

 

Understanding Dimensions and Metrics

Before we move ahead with custom dimensions and custom metrics, let us do a quick revision of dimensions and metrics. This will ensure that we all are on the same page.

A dimension is a characteristic of your visitor.

For e.g. for a visitor from London who arrived on my website via organic search term say ‘seotakeaways’ on Google.co.uk, the dimensions are ‘city’, ‘country’, ‘keyword’, source/medium etc. These dimensions characterize the visitor (i.e. the visitor is from London, England who searched for ‘seotakeaways’ via Google.co.uk) and this is how Google Analytics reports about a visitor to my site.

A dimension corresponds to a row in your analytics report.

Through dimensions you can break down a metric by a particular value like city, country, keyword, source/medium etc.

Custom dimensions are user defined dimensions. It means they are defined by people like you and me.

UA provides 20 custom dimensions.

A metric on the other hand is simply a number and it corresponds to a column in your analytics reports.

Visits, Conversions, Revenue, pageviews, bounce rate etc. are example of metrics.

Custom metrics are user defined metrics. It means they are defined by people like you and me.

UA provides 20 custom metrics.

Custom dimensions and custom metrics are available in UA custom reports and as a secondary dimension in standard UA reports. They can also be used in advanced segments.

Note: GA provides more than 200 predefined dimensions and metrics.

 

Setting up Custom Dimensions & Custom Metrics in Universal Analytics

Before I set up custom dimensions and custom metrics, I create a layout of my future report.

This layout is a blue print of what my report should look like:

UA-report-layout

From this layout I know that ‘Phone Call Keywords’ should be my custom dimension. Whereas ‘phone calls’, ‘admissions’, ‘call cost’ and ‘call duration’ should be my custom metrics.

Just to give you a context, I want to integrate the call center data with UA reports. My client runs a rehab center. His macro conversion is getting an admission to his center. His micro conversion is getting a phone call.  Therefore all conversions happen offline via phone calls.

Here e-commerce tracking is absolutely useless for me because no transaction is carried out online. Therefore it is absolutely critical for me to track these offline conversions via my UA reports and integrate them with predefined dimensions and metrics to get complete picture of the marketing campaigns.

The data in the table above would come from a call tracking software predominantly used by call center staff. My plan is to import this data into my UA reports via custom dimension and custom metrics.

Phone call keyword – this is the keyword which resulted in a phone call.

Phone Calls – this is the number of phone calls generated by a keyword.

Admissions – this is the number of people who admit to my client’s rehab center.

Call Cost – average cost of a phone call to the client.

Call Duration – as the name suggest, it is the average duration of a phone call.

Follow the steps below to create your first custom dimension:

Step-1: Go to the Admin section of your UA account and then click on the ‘Custom Dimensions’ link under ‘Custom Definitions’ drop down menu:

custom dimensions

Step-2:

new custom dimension  button

Click on the  ‘New Custom Dimension’ button.

Step-3:

add custom dimension

Enter the name of your new custom dimension, select its scope as ‘Hit’ and then click on the ‘create’ button.

custom dimension scope

Every custom dimension has got four scopes: Hit, Sessions, User and Product.

Hit is a call to the GA/UA server by an JavaScript library (like ga.js, analytics.js, urchin.js etc).

A hit can be a pageview, screenview, event, transactions, item etc.

  1. When a custom dimension has hit level scope, its value is only applied to the hit with which the value was sent.
  2. When a custom dimension has Session level scope, its value is applied to all the hits in the current web session.
  3. When a custom dimension has User level scope, its value is only applied to all the hits in the current and future web sessions of a user, until the value changes or the custom dimension is made inactive.

Note: You can’t delete a custom dimension or metric once you have created it. All you can do is then make it inactive if you don’t wish to use it.

Step-4:

example custom dimension code

Once you click on the ‘create’ button you will be shown the example code for your custom dimension. Just click on the ‘Done’ button for now.

You have now created your first custom dimension as shown below:

phone call keywords

Step-5:To create a custom metric, go to the Admin section of your UA account and then click on the ‘Custom Metrics’ link under ‘Custom Definitions’ drop down menu:

custom metrics

new custom metric button

Click on the ‘New Custom Metric’ button.

add custom metric

Enter the name of your new custom metric as ‘Phone Calls’, Set the scope to ‘hit’, Formatting type to ‘Integer’ and minimum value to ‘0’. I have specified minimum value of my ‘phone calls’ metric as 0, as you cannot get number of phone calls in negatives (like -10, -15 etc).

Note: Formatting type can also be ‘currency’ or ‘time’. It is actually the data type of the value your custom metric will store.

Step-6:

example code custom metricOnce you click on the ‘create’ button you will be shown the example code for your custom metric. Just click on the ‘Done’ button for now. You have now created your first custom metric. Similarly create your other custom metrics:

list of custom metrics

 

Step-7: Now comes the hard part (really hard part if you choose to do it yourself). You need the help of a web developer now. Forward the following example code for your custom dimension to your developer:

example custom dimension code2Note: You can get this example code by clicking on the name of your ‘custom dimension’.

Similarly forward example code for each of your custom metric to your developer. Following is an example code for a custom metric:

example code custom metric2Note: You can get this example code by clicking on the name of your ‘custom metric’.

Ask your developer to follow the environment (like SDK for Android, SDK for IOS) specific instructions in developer guide and populate the fields like ‘SOME_DIMENSION_VALUE’,  ‘SOME_METRIC_VALUE_SUCH_AS_123’ etc with the actual values.

He/she will write a script to do that.  So eventually it is my developer who sent the values for custom dimensions and custom metrics from call tracking software to UA reports through his code.

Step-8: Now create a custom report in UA with ‘Phone Call Keywords’ as primary dimension and ‘phone calls’, ‘admissions’, ‘call cost’ and ‘call duration’ as metrics:

UA-Custom-Report

Once you start getting the data, you will see a similar report like the one below:

UA-final-report

 

Points to remember about Universal Analytics

1. UA is most useful for multi-channel retailers (those who do multi-channel marketing both online and offline).

2. In UA almost everything from cross domain tracking, event tracking to e-commerce tracking is handled differently.

3. Remember the technical expertise needed to implement Custom dimensions and metrics. I have made it look all simple for you in this post. But the implementation is not that easy.

To learn more about upgrading to Universal Analytics, check out this post: Universal Analytics Upgrade Guide

Other Posts you may find usefulCommon Google Analytics Mistakes that kill your Analysis, Reporting and Conversions

Subscribe to my blog
Join my free newsletter and learn to avoid the analytics mistakes everyone seems to be making over and over again.

 

About the Author:

My business thrives on referrals, so I really appreciate recommendations to people who would benefit from my help.Please feel free to endorse/forward my LinkedIn Profile to your clients, colleagues, friends and others you feel would benefit from SEO, PPC or Web Analytics.