Learn business growth with Google Analytics 4 Forums Google Analytics 4 'GA4 Custom Dimensions Not Working Properly'

  • 'GA4 Custom Dimensions Not Working Properly'

    Posted by Rajesh on 10 June 2022 at 5:22 pm

    Hey there tech buddies, I need a bit of help. Somehow, I’ve managed to run into a little snag with ga4 custom dimensions with tag manager. It’s not really making sense to me. Data is being pushed, but only on the article pages using this snazzy script I have, where each has a unique article id.

    Here’s an example:

    window.dataLayer = window.dataLayer || [];
    dataLayer.push({
        'article_id': '35b65338-0c94-4a90-84a0-082ed420eae2',
        'type': 'article',
        'category': 'News',
        'subcat': 'Tourism',
        'pubdate': '2023-05-10-07:55AM'
        });
    

    However, the hitch is that the custom dimension isn’t syncing up. I’m puzzled because when I look at the screenshot, it should show #2 with pvu_article_id as my unique id, but instead I’m getting ‘(not set)’ and some mish-mash of article ids.

    Article Id Custom Dimension screenshot

    Even stranger, when I switch the custom dimension to sub category, it not only adds the dimension to the homepage, where I don’t even have the script, but also the article pages.

    sub category custom dimension screenshot

    Just for the record, I do have enhanced measurement enabled, and ga4 custom dimension is set to scope using a user property. On tag manager, it’s using a ga4 event tag using user properties and triggers on all pages for page views.

    Does anyone have an inkling why this is happening? I’ve tried different settings on both tag manager and ga4 custom dimensions but no luck. What I really need is for the script’s data to pass as custom dimensions, so I can filter out the articles when I’m reporting and in datastudio. For example, filtering out articles under the ‘Tourism’ subcategory.

    Any ideas, anyone?

    Quinn replied 1 year, 3 months ago 3 Members · 2 Replies
  • 2 Replies
  • Anthony

    Member
    5 December 2022 at 4:23 pm

    Sure, it sounds like you are having issues with passing data properly to your Google Analytics 4 (GA4) using Google Tag Manager. The data push should allow you to isolate certain articles based on specific details about them. However, currently, the “article_id” is not being correctly registered, causing mish-mash of the id’s and “(not set)” values in your reports.

    Similarly, when you try to register the subcategory as the custom dimension, it’s incorrectly showing up in pages where it’s not supposed to. Basically, your custom dimensions (which are the specific elements or attributes you want to track) are not working properly.

    One likely reason could be how your tags are set up in Google Tag Manager and how they are interacting with GA4. The custom dimensions need to be correctly set in GA4 and then properly deployed through Google Tag Manager.

    Unfortunately, without having a look at your actual GTM and GA4 setup, it’s hard to provide a definitive solution. This issue typically needs a hands-on approach to identify where things are going wrong.

  • Quinn

    Member
    26 April 2023 at 12:01 pm

    Based on your code, it seems you’ve done everything correctly. However, there is a chance you might be running into a race condition issue where the data is not fully registered before the page view event is sent.

    In order to debug this, I would suggest checking how you are setting your custom dimensions. Make sure you are using the correct dimension names in your GA4 configuration. You could also verify whether you have correctly set up your GA4 Custom Dimensions config tag in GTM and that the triggering occurs at the right time.

    Additionally, check if your dataLayer.push is executing before the GTM event trigger fires. If your dataLayer.push executes after the GTM event trigger, the data may not be included in the event.

    Lastly, check your GTM to GA4 data mapping. Ensure that you are mapping from the correctly named variables, and that ‘article_id’, ‘type’, ‘category’, ‘subcat’, ‘pubdate’, match exactly to your custom dimensions in GA4.

    Remember, the debugging process may take some time and require a lot of testing to make sure everything is set up correctly.

Log in to reply.