Learn business growth with Google Analytics 4 Forums Google Analytics 4 Google Analytics 4 – Using Custom Dimensions

  • Google Analytics 4 – Using Custom Dimensions

    Posted by Emma on 15 October 2022 at 8:43 am

    So I’ve made a few custom dimensions for my property like this:

    Name of Dimension
    Scope
    Property/Parameter

    event_category
    Event
    event_category

    event_label
    Event
    event_label

    When I’m checking my website in the analytics debugger, these parameters are showing up in the events for my GA4 tag:

    form_submission - Google Analytics Hit
        Page Location   dl  https://16v8x.elite80-001.ihousedev.com/contact
        Page Referrer   dr  https://tagassistant.google.com/
        Event Name  en  form_submission
        System Property _ee 1
        Event Parameter ep.event_category   lead
        Event Parameter ep.event_label  Contact Us
    
        API Call: 
        gtag("event", "form_submission", {event_category: "lead", event_label: "Contact Us"})
    
        Data Layer:
        {
          event: "form_submission",
          gtm: {uniqueEventId: 9, start: 1684510761995, priorityId: undefined},
          eventModel: {
            event_category: "lead",
            event_label: "Contact Us",
            send_to: "MY TAG"
          }
        }
    

    I thought adding these custom dimensions would let them show up in my reports, but it doesn’t look that way.

    $dimensions = [
            new Dimension( ['name' => 'eventName'] ),
            new Dimension( ['name' => 'customEvent:event_category' ]),
            new Dimension( ['name' => 'customEvent:event_label' ]),
        ];
    $metrics = [
            new Metric( ['name' => 'totalUsers'] ),
        ];
    
    $date_range = new DateRange( [ 'start_date' => '2023-04-28', 
                                   'end_date'   => date('Y-m-d')
                                 ] );
    
    $report_params = 
        [
            'property'   => "properties/MY PROPERTY ID",
            'dateRanges' => [ $date_range ],
            'dimensions' => $dimensions,
            'metrics'    => $metrics,
        ];
    
    $response = $client->runReport( $report_params );
    

    If I leave out the two new custom dimensions, I see most of the events I’m expecting. But, if I add in either or both, nothing shows up. Did I screw up the specs for the custom dimensions? Or do I need to wait for events I triggered after making the new dimensions? I thought the values for category and label would be in the existing events, but maybe not. The long delay between doing stuff on my website and the events showing up in GA4 is seriously putting a dent in my testing.

    James replied 1 year ago 3 Members · 2 Replies
  • 2 Replies
  • Addison

    Member
    20 March 2023 at 5:59 am

    It sounds like you’re having trouble with the custom dimensions not showing up in your reports in Google Analytics 4. For custom dimensions to work, you not only need to set them up in the GA4 interface, but you also need to make sure you’re sending the correct parameter values within your tracked events. From what you shared, it seems like you’re sending the ‘event_category’ and ‘event_label’ parameters correctly in your events.

    However, in your report call, it looks like you’re asking for ‘customEvent:event_category’ and ‘customEvent:event_label’ instead. I think this might be the issue, as your events are not sending those exact parameters. Instead, try asking for ‘event_category’ and ‘event_label’ within your dimensions array and see if that makes any difference.

    Additionally, keep in mind that there can be delays in reporting in GA4, so it could very well be that the custom dimensions have simply not had time to populate in your reports yet.

  • James

    Member
    9 June 2023 at 8:15 pm

    In Google Analytics 4 (GA4), the implementation of custom dimensions and parameters is different from the previous versions. When you define new parameters in the GA4 interface, these parameters start to work from that moment onwards. They won’t retroactively apply to events that happened prior to their creation. This could be why you aren’t seeing these custom dimensions in your reports.

    In addition, to successfully track and report custom parameters, they must not only be sent in your GA4 event tags, but also registered in the GA4 interface. From your code, it seems you are correctly sending the parameters (event_category and event_label) via your gtag() call, and I assume you have also set them up in the GA4 interface.

    The delay you’re experiencing between triggering events on your website and those events appearing in GA4 is normal. Real-time reporting in GA4 is not immediate unlike Universal Analytics, and it can take between 24-48 hours for standard events and custom dimensions to appear in most reports.

    Ensure you’ve correctly defined your new dimensions: they should be set up as “event scoped”, and their names should be exactly as they appear in your code. Also consider waiting for at least 48 hours to see if the new parameters start to appear in your reports. You may want to reach out to a Google Analytics expert or Google’s support for an in-depth look into your specific situation.

Log in to reply.