Many people think that gtag.js can not set a Client ID in a Custom Dimension.
However, although the official document itself does not exist, it is still possible to set the Client ID in Custom Dimension in gtag.js. The method is much easier compared to the days of analytics.js up to now.
Let's show you how to set Client ID in Custom Dimension using gtag.js.
How to Configuration
Add a Custom Dimension in Admin Page
Please add it from the Google Analytics User Interface. Since it is published in official, we will omit it in this article.
How to Customize of Tracking Code
The following code is an example of configuration a Client ID on Custom Dimension 1.
gtag('js', new Date());
gtag('config', 'UA-xxxxxxxx-y', {
'custom_map': {
'dimension1': 'clientId'
}
});
We have made changes to gtag's config command using custom_map. We can map it to the Google ANalytics default key name(such as clientId).
Current Issues
By using the method described above, it is possible to set the Client ID as a custom dimension already. However, we can not answer the need to send this Client ID value "to another CRM". As for here, we need to continue investigating.
Conclusion
In this time, I introduce "how to set Client ID as custom dimension with gtag.js" which seems not to be found anywhere yet. There are some features that are not yet available in gtag.js. But there are "some features that I thought could not, but actually implemented".