Learn business growth with Google Analytics 4 Forums Google Analytics 4 Accessing Event Data with Custom Properties in GA4

  • Accessing Event Data with Custom Properties in GA4

    Posted by Isabella on 26 May 2023 at 10:11 am

    “Hey all,

    I’ve got a little problem. I’m using GA4 to keep track of all the applications our customers have installed. We need to know which versions they’re running. Our app is a web app (WAR) on Tomcat.

    For each webpage that’s generated and sent to the client browser, we’ve added this gtag script: gtag('config', 'OUR-COMON-GA4-ID', {'app_version': '1.0.1'});. We include extra config info (https://developers.google.com/tag-platform/gtagjs/reference#config), which GA4 attaches to each logged event.

    But here’s where things get tricky. How do you read this extra info using the official JAVA library for GA4? We need to figure out the app versions that are generating each event.

    Also, when I attempted to add a new dimension addDimensions(Dimension.newBuilder().setName("event_params.app_version")), I ended up with an error: INVALID_ARGUMENT: Field event_params.app_version is not a valid dimension. The thing is, without this dimension, I can read the data successfully! I’ve got some code here if it helps you figure out what’s going on:

    [CODE BLOCK]

    Can anyone out there help me understand how to read this data?

    Thanks a million!”

    Avery replied 1 year, 5 months ago 3 Members · 2 Replies
  • 2 Replies
  • William

    Member
    16 June 2023 at 3:21 pm

    The issue likely lies in how your custom event parameter is interpreted by GA4 – it’s possible that “event_params.app_version” isn’t defined as a dimension in GA4. You might need to manually configure it in GA4 as a custom dimension first before using it in the JAVA library. Try defining app_version as a custom dimension in your GA4 dashboard, relaunch your app, then you should be able to access it as expected.

  • Avery

    Member
    26 June 2023 at 8:13 am

    It seems like you’re trying to add a new custom dimension in GA4 which might not be created at the GA4 interface first. You have to create it there and ensure it’s correctly set as an event-scoped dimension. Getting the data through Java could be more about API querying. If you’ve got the dimension set right, then it might be more about properly fetching the data with the right API call.

Log in to reply.