Learn business growth with Google Analytics 4 Forums Google Analytics 4 Troubleshooting GA Data API: pageLocation Dimension Error

  • Troubleshooting GA Data API: pageLocation Dimension Error

    Posted by Peyton on 28 June 2022 at 8:05 am

    Hey there! 👋 I’m in the middle of migrating from UA to GA4. I’m trying to grab the full page URL using GA Data API in my Spring Boot app. I’m using the API name for the ‘Page Location’ dimension in the yaml file. Runs great for ‘browser’ and ‘country’, but when I add ‘pageLocation’, my app’s not having it — keeps throwing up an invalid argument exception and yelling at me about a ‘Bad Request’. Supposed to work according to the docs. Can you help with this?

    Here’s the code snippet, by the way:

    dimensions:
         - name: "browser"
         - name: "country"
         - name: "pageLocation"
    

    Appreciate any help you can give. Thanks!

    Henry replied 1 year ago 3 Members · 2 Replies
  • 2 Replies
  • Elijah

    Member
    15 April 2023 at 7:19 pm

    The error message you’re receiving is likely due to the fact that in Google Analytics 4 (GA4), the dimension corresponding to the full page URL is not ‘pageLocation’, like it was in Universal Analytics (UA), but ‘page_location’. In GA4, dimension names in API calls need to be in snake case (all lowercase with underscores) instead of camel case. Change ‘pageLocation’ to ‘page_location’ in your code, and it should work fine:
    `
    dimensions:
    – name: “browser”
    – name: “country”
    – name: “page_location”
    `

  • Henry

    Member
    24 April 2023 at 3:50 pm

    Sure, I’d be glad to help. The issue you’re experiencing stems from a naming discrepancy. In GA4 associated with the GA Data API, the dimension name for full page URL is ‘pageLocation’ in Universal Analytics (UA), but in Google Analytics 4 (GA4), it has been renamed as ‘page_referrer’. Therefore, correct your YAML file to reference ‘page_referrer’ instead of ‘pageLocation’ as shown here:
    `
    dimensions:
    – name: “browser”
    – name: “country”
    – name: “page_referrer”
    `
    Give this a shot and it should solve your problem.

Log in to reply.