How to Add Client ID to a Custom Dimension with Gtag.js


Migrating to gtag.js is about more than just replacing your current analytics.js tracking library — it also gives you the chance to change how you add custom dimensions. In fact, gtag.js simplifies the process significantly. One place this is especially true is for Client ID, as gtag.js eliminates the need to use customTask or the ga.getAll() tracker method.

Adding Client ID to a Custom Dimension

All you need to do to add Client ID with gtag.js is use this:

gtag(‘config’, ‘UA-11111-1’, {

 ‘custom_map’: {

   ‘dimensionX’: ‘clientId’




In place of “UA-11111-1,” input your Universal Analytics tracking ID. For “dimensionX,” add your own custom dimension index. That’s it — you’ve added Client ID to a custom dimension.

As this task takes almost no time at all, there’s no reason not to do it. Then, you’ll be able to see reports with different rows for each Google Analytics user without needing to use User Explorer reports.

Gtag.js is still new and many users as yet have not adopted it. This means that there are likely many other potential uses of the tracking code still to be discovered. Even adding Client ID to a custom dimension is still missing official documentation. On the flip side, some features are still unavailable. However, it is likely that Google will keep expanding on capabilities as time goes on.

If you like my articles,