Beginners Guide to Universal Analytics - Creating Custom Dimensions & Metrics

 

Universal Analytics (UA) is going to change the way we look at the data for good. One year from now, our analytics reports will be unrecognizable. I have been using 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

Data Collection and Integration - Universal Analytics (UA) provides more ways to collect and integrate different type 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, demographic 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.

UA uses custom dimensions instead of custom variables - Conversely 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. There are not any new reports in UA yet. 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.

Note: UA now supports features like ‘Google Adsense’, ‘Remarketing’ and ‘Content Experiment’.

In UA referrals are processed differently. By default all referrals trigger a new web session in UA. This can affect the 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. When the visitor returned back to www.xyz.com from www.abc.com, it will trigger another new web session. So in total 2 web sessions will be triggered in UA:

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 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).

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 features – UA lets you change following server side configuration features via the account admin panel:

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

UA-edition

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 this:

utm

 

Setting up Universal Analytics

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

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

Step-2: Go to ‘Admin’ area and then click on ‘new property (web or app)’ button to create a new ‘web property’ in your existing Google Analytics account as shown below:

new-property

Step-3: Select ‘universal analytics’ in the ‘select a tracking method’ section as shown below:

like-to-track

Enter your website name, website URL. Select your industry and reporting time zone as shown below:

get-tracking-id

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

Step-4: 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. Remember this tracking code is different from the standard GA tracking code.

Note: If you want to use Universal Analytics for your existing website then copy-paste the new universal analytics tracking code next to your standard Google Analytics tracking code like this:

GATC-UATC

According to Google, you can use both of the tracking codes on the same web page and this will not cause any tracking issues. However I noticed that the Google Page Speed Score went down by 1 point when I implemented both GA and UA tracking codes. Website speed is something you need to keep in mind if you opt for double tracking.

Note: If you are using both UA and GA tracking codes then you can’t enable Google Webmaster Tools data in your UA account without losing access to the Google Webmaster Tools data in your GA account. This is because only one web property at a time can be linked to a website in your Google Webmaster Tools account.

Step-5: Check the source code of the home page and other web pages on your site 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.

Step-7: Set up custom dimensions and custom metrics.

 

Change session and campaigns timeout settings

Go to the ‘Admin’ panel of your account and then click on Tracking Info > Session Settings:

session-settings

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 your visitor visited the site. There are certain situations in which you may need to change the 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: 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)

If you want to change session timeout in GA (instead of Universal Analytics) then you need to call the _setSessionCookieTimeout() method from your Google Analytics Tracking code. 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’ panel of your account and then clicking on Tracking Info > Organic Search Sources

organic-search-sources

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 filled out your form in a similar manner and clicked on the ‘save’ button. You can then see your search engine added to the default list:

organic-search-sources3

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. 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’ panel of your account and then clicking on Tracking Info > Referral Exclusion List

referral-exclusion

referral-exclusion2

Here I am excluding my own domain name seotakeaways.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’ panel of your account and then clicking on Tracking Info > Search Term Exclusion List

search-terms-exclusion

search-terms-exclusion2

Here I am excluding my own domain name 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

Before I set up custom dimensions and 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. I am planning 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 panel of your UA account.

Step-2: Click on ‘Custom Definitions’ tab and then on ‘New Custom Dimension’ button:

new-custom-dimension-button

Step-3: Enter the name of your new custom dimension, select its scope and then click on the ‘create’ button as shown below:

add-custom-dimensions

Every custom dimension has got three scopes: Hit, Sessions and User. When a custom dimension has hit level scope, its value is only applied to the hit with which the value was sent.

Note: Hit is a call to the GA/UA server by different libraries (like ga.js, analytics.js, urchin.js etc). A hit can be a pageview, event, transactions or item.

When a custom dimension has Session level scope, its value is applied to all the hits in the current web session. When a custom dimension has User level scope, its value is only applied to all the hits in the current and future web sessions, 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: 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.

your-first-custom-dimension

Step-5: Now click on the ‘custom metrics’ tab and then on the ‘new custom metric’ tab to create your custom metric as shown below:

add-custom-metric

Here formatting type can be ‘integer’, ‘currency’ or ‘time’. It is actually the data type of the value your custom metric will store. 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).

Step-6: Once 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:

other-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-code-dimension

Note: 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-metric

Note: 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. Once you start getting the data, you will see a similar report:

UA-Custom-Report

UA-final-report

 

Should you upgrade to Universal Analytics?

UA is most useful for multi-channel retailers (those who do multi-channel marketing both online and offline). UA is not useful for every type of website/business. For example UA is not very useful for seotakeaways.com, as I don’t run an e-commerce store and I don’t have an offline store/presence. So before you switch, you need to evaluate your business/marketing needs to use UA. Not everybody needs UA.

Even if you decide to use UA, instead of upgrading, consider running Universal Analytics in parallel to your standard GA account at least for the next 3 months and see how it goes. This is what I have being doing. You can do this by adding both GA and UA tracking code on all the web pages of your website. Avoid removing the standard GA tracking code just to implement the UA tracking code on your website for the time being. This is because:

1. In UA almost everything from cross domain tracking, event tracking to e-commerce tracking is handled differently and there is not enough support available from Google and other analytics users yet. If anything goes wrong you are pretty much on your own.

2. UA is still in beta. Which means it is not very reliable. I have noticed UA treating organic traffic as direct traffic in some cases and there are some other issues too.

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. Don’t remove the standard GA tracking code from your website unless you are absolutely confident in your ability to do all the work in UA.

 

If you like this post then you should subscribe to my blog and follow me on twitter

 

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

 

Himanshu Sharma About the Author: is the founder of seotakeaways.com which provides SEO Consulting, PPC Management and Analytics Consulting services to medium and large size businesses. He holds a bachelors degree in ‘Internet Science’, is a member of 'Digital Analytics Association', a Google Analytics Certified Individual and a Certified Web Analyst. He is also the founder of EventEducation.com and EventPlanningForum.net.

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.

 

 

  • analytic geek

    good one! bookmarked

  • Moe

    Thanks for the awesome post as usual. What I am wondering is, will UA link the offline conversion to the online visit, or it will just collect offline and online data separately.

    For ex.: If a user visits a website, then calls the office. Will we be able to see the keywords that drove the phone call conversion, or will it just report a phone conversion with no attribution to the online source?

    • seohimanshu

      UA can link the offline conversions to the online visits, keywords etc. That’s the main purpose of using UA.

      • Moe

        Yeah I know, although they will use a unique client ID to identify visitors. What I am missing though is how will it be able to provide the caller the same client ID as the one given to the visit.

        How will it be able to identify that this visitor that came to the website is the same as the one that called thus giving it the same client ID,

        • seohimanshu

          Almost all call tracking softwares are able to connect each phone call back to the originating source and keyword and assign them unique client ID. They are able to do this by a special tracking code which they ask us to put on our website. I don’t know exactly how this tracking code works but it is able to do the things you are talking about.

  • http://twitter.com/Bealodano Beatriz López

    Hi! first, thank you very much, a really completed post. Congrats because it is useful. However I have tried to add the universal tracking code just behind the google analytics one and save in my website (wordpress.org, header.php file). I did it in header.php file but I cannot see UA working. Just few questions, any tip? is it configure (in a pararell way) at account or web profile level? Do I need to ask any kind of special access? I doublechecked in real time reports with no result. Thanks in advance! Bea

    • seohimanshu

      Hi Bea! It is hard to diagnose your problem without actually looking into your account. Make sure that the formatting of your UA tracking code is correct. Sometimes change in formatting can stop the tracking code from working properly. Any extra comma, space or character can stop your tracking code from working. Copy-paste the UA tracking code from your Universal Analytics account directly into your header.php file. Then check the source code of your home page and search for ‘analytics.js’ file. If you can see this file in the head section of your web page then the UA tracking code is installed otherwise it is not installed. UA is set up at the property level if you have multiple web properties otherwise on the account level. You may have to wait for up to 4 hrs once you have set up the new tracking code before you can see any new data.

      • http://twitter.com/Bealodano Beatriz López

        I got it:) Thank you very much for your words and support, really appreciated. It was a matter of time, you we’re right, I haven’t done any change and started capturing data:) I will continue working and going into more detail.
        On the other hand, I have prepared a post in Spanish with my research and steps I have followed. I have mentioned your blog - just FYI
        Thank you again for your time, all my best, Bea

        http://www.misideasdospuntocero.es/comenzamos-con-universal-analytics/social-media-consultoria/

        • seohimanshu

          Thanks for the mention and reading this post.

  • vimal

    Awesome Post!!

  • alvaro

    Thank you very much for this wonderful article!!

    • seohimanshu

      I am glad you find it useful.

  • http://www.facebook.com/muhali786 Muhammad Ali

    Very Informative, Very Juicy, Very Clicky. Himanshu Keep Sharing Good Stuff.
    Thanks
    Best Regards

    • seohimanshu

      Thanks for the kind words

  • Hugo

    Hi,

    Very good tutorial, thank you very much !

    One small question though: where should you drop the scripts used to populate custom variables / metrics ?

    Cheers

    • seohimanshu

      You place the script on the page where you want to collect the data.

      • Hugo

        Yes, I guess so,but is it to be placed above the main UA script or below ? Does it have no importance whatsoever ?

        Thanks :)

        • seohimanshu

          Generally all the code is placed below the main UA script.