Learn business growth with Google Analytics 4 › Forums › Google Analytics 4 › Troubleshooting Custom Dimension in Google Analytics with gtag set() Method › Reply To: Troubleshooting Custom Dimension in Google Analytics with gtag set() Method
-
Sure, here’s the gist of the situation:
The
gtag set
method doesn’t function as you might expect. It’s primarily useful for altering the DL for GTM’s benefit, but it doesn’t do much for setting properties. Nevertheless, you have alternatives.One method is to define the params directly within the event call, like this:
gtag("event", "Button click", {chain_id: "test id"});
.Please see this console snapshot for reference: [Console_Snapshot](https://i.stack.imgur.com/H2vhw.png)
Another method is to set the eps through the config, which will make them persist. See this snapshot for reference: [Event Snapshot](https://i.stack.imgur.com/8rt2o.png). However, please take note that Google recently updated for ignoring configs issued after the initial config. So, if you aim to modify persistent event parameters for all following events by issuing a config and gtag.js just disregards it, you might want to check out this discussion: [GA4_custom_dimensions_discussion](https://stackoverflow.com/questions/76177242/can-ga4-custom-dimensions-be-updated-after-the-initial-config-call/76222825#76222825)
In conclusion, I highly recommend you to consider using Google Tag Manager (GTM) or any other TMS. It simplifies the process of implementing, managing, scaling, and supporting tracking. Using gtag.js for tracking is practical when your tracking needs are minimal and it doesn’t affect your long-term business results.