Track custom var on Google Analytics Universal (analytics.js): the Custom Dimensions

There are two kind of Google Analytics accounts: Classic, the standard version, and Universal, a new version of analytics, currently in public beta.

In Google Analytics Classic, you can use Custom Variables for tracking additional data in Google Analytics (e.g. logged/unlogged user, male/female visitors, levels in games, etc.).

In Google Analytics Universal, you can’t use custom variables but you can use Custom Dimensions.


Differences and advantages between custom vars and custom dimensions

The difference between custom variables and custom dimensions is that the former are handled on client side, while the latter are handled on server side.

These are some advantages of Custom Dimensions compared with Custom Variables:

  • For tracking custom dimensions, Google Analytics send only the index and the value of the custom dimension and it send them at collection time and not in each hit
  • For editing custom dimensions, you can edit property settings on your analytics account, without modifying your code


1) Create a custom dimension

Before you can send data as custom dimension, you must create it in your account property.

For creating new dimension, these are the steps:

  1. Go in any page of your Analytics account and click “Admin”
  2. Select account and property which you want add custom dimensions and click Custom Definitions and Custom Dimensions
  3. Click New Custom Dimension
  4. Add the name of custom dimension
  5. Select the scope of custom dimension
  6. Check Active radio button for activing it
  7. Click Create


The custom dimensions can have 3 different scopes:

  • Hit-Level Scope
    The value of custom dimension is applied only to the hits which the value was set
  • Session-Level Scope
    Once you set the custom dimension, all the successive hits will be identified with it. In the case in which is defined a new value for the custom dimension, all the events of that session are identified with the new value
  • User-Level Scope
    Equal to Session-level scope but it’s applied also for future sessions of that user


2) Track events and send data

You can send a dimension with an pageview event:

ga('send', 'pageview', { 'Level' : 'Customer' });

in this case, Level is the name of dimension and Customer is its value

You can send a dimension with an event:

ga('send', 'event', 'UI', 'click', 'Menu', { 'Source', 'Banner' });

in this case, ‘UI’, ‘Click’ and ‘Menu’ are category, action and label of event, while ‘Source’ is the name of dimension and ‘Banner’ is its value

You can set a custom dimension for old and new events and pageviews (it depends on the scope):

ga('set', 'User', 'Logged');

in this case, ‘User’ is name of dimension and ‘Logged’ is its value


3) Read report of custom dimensions

Custom dimensions are available for advanced report and as secondary dimensions in standard reports.

Aurelio Merenda

I live in Florence (Italy). I graduated in IT in 2010, I work as Front End Developer in Buongiorno, a NTT Docomo Group company. I specialize in Javascript & AngularJS. I like photography, movies and cats.