Custom Dimensions and Metrics

Key Concepts of Custom Dimensions and Metrics

google analytics automatically collects a long list of built-in dimensions but we can create specific dimensions

Custom Dimensions and metrics are property level configurations and when created, will appear under all views under the property.

They are only available under universal analytics, or android and IOS property setups.

Free version: 20 custom dimensions/metrics per property

Paid version: 200 slots available for custom dimensions/ 200 metrics

You cant not delete custom metrics or dimensions, only disable them or edit them.


  • scope determines to what level they will be applied
  • four levels scope are available for custom dimension and metrics
  • hi: only applies to certain hit such as page-view or event
  • session: applies to all hits within a session
  • users: applies to all hits generated by user
  • Products: (applies to enhance eCommerce tracing only); applies to all hits that contains product data

After adding a custom dimension or metric, GA allocate an index number to it

The index number will be used later for data collection

To collect data into custom dimension, use following syntax:
ga(‘set’,'<custom dimension index>’,'<value>’);

For example, right before pageview hit, you can run the following command to identify user login status:

To collect data in a custom metric, use following syntax:
ga(‘set,'<custom metric index>’,'<value>’);

For example, right before an event hit, run the following command to collect
users rating for a content:
ga(‘set’,’metric1′,’3 out of 5′);

There is no command to directly collect custom dimensions or metrics through command queue and data is always being collected attached to one of the hits types.

For example, you can collect user login status as apart of a pageview hit

to collect data into custom dimension, use the following syntax:
ga(‘set’,'<custom dimension index>’,'<value>’);

For example, right before pageview hit, you can run the following command to collect user login status:

ga(‘set’,’dimension1′,’not logged-in’);

Custom dimensions and metrics can be used similar to default dimensions and metrics in any report. You can only cross correlate custom dimension and metrics on the same scope that are on the same level.


Google Analytics Tracking Code and Actions

In this post I will break down the elements of your Google Analytics Tracking code and cookies.

Your tracking code can be found in your analytics admin under property settings,  It will look similar to this:

<!– Global site tag (gtag.js) – Google Analytics –>
<script async src=”*********-***”></script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(‘js’, new Date());

gtag(‘config’, ‘UA-*******-**’);

  • Ga uses ga() command queue for various tracking methods including:
  • Create: creates a new tracker instance with the specified fields
  • Send: sends a hit to google analytics
  • Require: dependant on analytics.js plugin
  • Provide: Provides analytics.js plugin and its methods for use with the ga() command queue

Command syntax
Ga(command, […fields],[fieldsObject])
Example: ga(‘create’,’UA-*******-*’,’auto’);

  • GA requires a tracker object for data collections
  • Tracker objects  collect and store data and then send that data to Google Analytics
    • Default implementation creates tracker object by running the following command:
  • This command creats a tracker object by passing “UA-*****-*
    as the Tracking ID and “aucto” for the configured domain name
  • Without setting a specific name for the tracker the defualt tracker is internally given the name “to”
    • To change the tracker object’s name, use the folling command:
      ga(‘create’, ‘UA-*******-*’, ‘ auto’, ‘ TrackerName’);

Configure Cookie and Session

A browser cookie is being used to determine that two or more distinct hits belong to a user







GATC generates a unique randomly generated Client ID and stores it in a first party cookie. By default the cookie name is _ga.   This cookie is allocated to the top level domain and all of its subdomains, other domains require cross-domain tracking.

GATC generated the cookie by this command: ga(‘create’,’UA-*******-*’,’Auto‘);

Tracker object

If you customize the tracker object name all other commands should be sent to that object

With default object:

With custom name:

Configure Cookie and Sessions

To customize the cookie use the following command:
ga(‘create’,’UA-*******-*’, {
‘cookieDomain’:’’,       <default is document.location.hostname>
‘cookieExpires’:60*60*24*28    <sets cookie expirey time in seconds,default is 63072000 or two years>

Expiry time doesn’t have anything to do with session timeout.  Session timeout can be set in GA admin panel under Tracking info>Session settings.

Full list of tracking objects can be found here.


The Structure of Google Analytics

When you have successfully install your Google Analytics Tracking Code (GATC) your browser executes a HTTP Get request to the GA data server.

This Get request is called a GA Beacon, GA Payload, Server Call or a simply a Hit.

GA components on the client side:
-Tracking tag
-Custom tags for advance data collection

GA components on the server side
-properties / View configurations
-user management

Its important when you first setup GA to immediately create a second view of your data,  If you make a mistake with your setup there is no backward filling that missing data.  And avoid having your account penalized, no personally identifiable info is allowed to be collect.  If done you may lose your account.

Your basic GA daseboard has dimensions for various purposes:

Base data:
-Page Views

Web Design and Development:
-Page engagements
-Browsers and technologies
-Devices types


Event tracking in Google Analytics

Event tracking is used to track specific elements on a page, there are two primary ways of doing this either as a basic event trigger which will only measure click or to setup an event as a page view so that other metrics are captured.   But it requires some setup triggers.

Method one:  Events are reported under Behavior -> Events and/or Real time -> Events.
An Event can be interactive or not depending on where you use it.

Event data has four descriptors:

  • Category (required) name you supply for the group of object you want to track
  • Action (required) a string that is uniquely pared with each category, and commonly used to define the type of user interaction for the web object.
  • Label (optional) provides additional dimensions to the event data
  • Value (optional) you can use this to provide numerical data about the user
  • non-interaction (optional), a boolean that indicates that the event hit will not be used in bounce-rate calculation.

This is the headings the reports are grouped by.  Its best to create a standard for data in all headings.  Examples suck as click, hover, submit would be in “Action”.   Making sure all these headings are filled will help you create complete reports faster.

Event  function in universal analytics:

ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);


ga('send', 'event', 'Videos', 'play', 'Fall Campaign');

Code on page: <button type=”button” onclick=”ga(‘send’,’event’,’Click’,’Signup’,’Buttom’,0); “onmouseover=”ga(‘send’,’event’,’Hover’,’Signup’,’Bottom’,0);”>sign up</button>

Event tracking as a page view

Having your event track as a page view will allow you to get more insight on how they interact with your site.  Where they leave, how long they spent on each page and you can create conversion funnels with your goals.  The issue with this method is it will add to page view and session bloat.

metrics it impacts:

  • Time on page
  • Pages/sessions
  • Entrance
  • Exit
  • Bounce
  • Session duration


ga('send', 'pageview', location.pathname);
ga('send', {
  hitType: 'pageview',
  page: location.pathname

Modifying page url, Label the virtual ones distinctly so you can tell it apart.
  • /user/USER_ID/profile
  • /user/USER_ID/account
  • /user/USER_ID/notifications

These type of interactions are important for ajax driven single page websites where the url doesn’t change.

Clickstreams and data collection in analytics

Basically clickstreams is a methodology of determining the pathway users are taking through your site.

Whenever a user interacts with your site and its various elements this data is being stored in a log file in Google analytics or whatever analytical platform you are using.  In order to achieve this three components are used;  page titles, browser cookies, and a web server log file.  This log file is processed by Google analytics to create reports in your console.

Web analytics can never be completely accurate. When you have a high volume of visits, the quality of your analysis can be hampered by sampled data.  Some reasons this data could be slanted is; improper page coding, disable JavaScript in browsers, interrupted connections and firewall preventing data being collected. The same user using multiple devices as well as multiple users using the same computer will also effect the data collected.

It’s up to your Google analytics admin to filter and and segment this data to be accurate enough for actionable analysis.


Metrics and Dimensions in analytics

  • Dimensions normally fall on the right site of the table in google analytics its defined as attributes of your web visitors.
  • Metrics are strictly are the numbers

The following are common dimensions or attributes:

  • Gender
  • Age
  • City
  • Source/medium
  • Keyword
  • Browser
  • Device
  • Operating system

The following are metrics:

  • Sessions
  • New users
  • Bounce rate
  • Pages
  • Avg. Session Duration
  • Goal Conversion Rate
  • Goal Value

Google only allows metrics to be queried in the reporting interface, for example you cant query cities.

Metrics only useful when defined by a dimension.  What good is knowing the bounce rate if you don’t know the page.

Metrics can be reported in three categories.  Acquisition metrics, Behavior Metrics and conversion Metrics.  With these options you can see how they came to your site, how long they stayed, where they when and if they purchased or signed up.


Analytical methodologies and Key Elements

There are may ways of collecting quantitative web data but one of the more tried and tested is Clickstream data collection

Clickstream is the process of collecting, analyzing and reporting aggregate data about which pages a website visitor visits — and in what order. The path the visitor takes though a website is called the clickstream.

Clickstreams uses cookies and log files and page tags to gather this data.

There are lots of commercials tools available that use clickstreams for their data.

Open Source Self Hosted tools

What is Web and Digital Analytics

From Wikipedia

The World Wide Web is a global collection of documents and other resources, linked by hyperlinks and URIs. Web resources are usually accessed using HTTP, which is one of many Internet communication protocols.[32]


Originally created by the US department of defense to network several computer science laboratories of their own and of their allies. The web started off as a top secret project named  ARPANET

The grandfathers of all web developers Robert E. Kahn and Vint Cerf in the 1970s created the Internet protocol suite (TCP/IP) that we still use to this day.

It wasn’t till the mid nineties the internet that we currently know and enjoy allowed for commercial traffic.

I still remember the very first website I every visited being a very slow Library site with minimal content a nauseating screen color of #09dad0.
Only children of a certain generation can appreciate the frustration of those first dial up modems.  These mid-evil dark times where you had to pick whether to be able to use the phone or be online.  And if a sibling or parent picked up the phone you would be immediately disconnected and you would have to dial in all over again.

Now there internet is our primary mode of telecommunication,  information and entertainment the challenge is to stand out from the noise.

The most valued trait for modern marketers is is to be able to properly analyze website data and competitors data.  Store and cleanse that data and make it easy to understand for a variety stockholders.

For example if you had an eCommerce store you would be looking at your traffic acquisition, SEO and SEM. your users experience and funnel through your site and to measure your conversions.

Over the last 10 year Google Analytics continues to be leader in the data measuring game.  The platform continues to be free and grows as technologies change.  There is huge business value in being able to keep up and master the tools provided by google.

V1 = what the business spend on advertising monthly
V2= how many clicks are generated
v3= conversion rate
V4= average conversion value

v2 x v3 x v4= business income v5  / Return On Advertising Spending  ROAS

v5 – previous months v5 = the economic value of web analytics

If a business spends $1,000 a month on digital advertising and garners 6,000 clicks and 300 newsletter signups. your conversion rate would be 0.05% .  If you give news letters a value of 1 dollar.

Through the campaign the business makes 6,000 x 0.05% x 1.00 = $300 ,  In this case you might want to give more value to your signups and/or rethink the targeting/spend of your campaign.

Conversion rates are calculated by simply taking the number of conversions and dividing that by the number of total ad clicks that can be tracked to a conversion during the same time period. For example, if you had 50 conversions from 1,000 clicks, your conversion rate would be 5%, since 50 ÷ 1,000 = 5%. : Google