Wednesday, May 8, 2024
HomeWeb AnalysisHow to set client id as a custom dimension in gtag.js ?

How to set client id as a custom dimension in gtag.js ?

If you’re using gtag.js right now, many of you may be thinking that you can’t set the client id in a custom dimension. However, although there is no official documentation, it is possible to set the client ID as a custom dimension in gtag.js as well. The method is much simpler than it used to be in analytics.js.

Now, I will show you how to set the client ID to a custom dimension using gtag.js.


Setting method

Add custom dimensions

Add from the Google Analytics management screen. Since this is also published in the official help etc., I will omit it in this article.

Customize your tracking code

The following is an example of setting the client ID in custom dimension 1.

gtag('js', new Date());
gtag('config', 'UA-xxxxxxxx-y', {
  'custom_map': {
    'dimension1': 'clientId'
  }
});

The config command of gtag is modified using custom_map. custom_map takes advantage of the fact that you can use not only the key names you define yourself, but also the default key names of Google Analytics.

Current issues

Using the method described above, it is already possible to set the Client ID as a custom dimension. However, it cannot meet the needs of “I want to send this client ID value to another CRM”. We need to continue investigating this.

summary

This time, I introduced “How to set the client ID as a custom dimension with gtag.js”, which seems to have not been posted anywhere yet. There are some functions that are not yet available in gtag.js, but there are also “functions that I thought I could not do, but can actually implement”. We would like to share such features as soon as we find them.

RELATED ARTICLES

Leave a reply

Please enter your comment!
Please enter your name here

Recent Posts

Most Popular

Recent Comments