Learn business growth with Google Analytics 4 › Forums › Google Analytics 4 › Enhancing Analytics Tracking with Custom Dimensions in Google Analytics 4 › Reply To: Enhancing Analytics Tracking with Custom Dimensions in Google Analytics 4
-
Unfortunately, you cannot directly pass the Universal Analytics (UA) custom dimensions to Google Analytics 4 (GA4) without making changes to your JavaScript code. This is because UA and GA4 handle custom dimensions differently. UA uses a flat structure with custom dimensions & metrics being numbers (like dimension1, dimension2), but GA4 utilizes an event-based model and its custom parameters are named.
It means you’ll have to modify the JavaScript code to handle GA4 custom dimensions (user properties). You’d need to, for example, use
gtag('event', 'some_event', {'dimension_name': 'value'});
for GA4.You also can’t use the same custom dimension tag to send data to both your UA and GA4 properties because of their different implementations. They would need separate tags.
Remember to set up the new custom dimensions in GA4, then in GTM ensure your tags reflect the different custom dimension structure of GA4 compared to UA. Finally, thoroughly test everything before fully migrating.
Keep in mind that enabling GA4 does not mean you have to immediately stop using UA. Both can and should run simultaneously during your transition.