Learn business growth with Google Analytics 4 Forums Google Analytics 4 How can I retrieve the totals field in batchRunReports for GA4?

  • How can I retrieve the totals field in batchRunReports for GA4?

    Posted by Xavier on 10 September 2022 at 6:36 am

    “Hey guys, I’m bummed. I’ve been messing around with GA3(UA) and I could totally get the total of each metric from their API batchGet endpoint, without having to dig through each row. It was such a breeze!

    But then I moved to GA4 and guess what? No total field came back from the API. Have any of you gone through the same muddle and figured it out? I noticed a similar question floating around but it was sooo into a specific language that I couldn’t make head or tail of it. BTW, I’m using Postman to create the request.

    I even tried to make sense of the GA4 documentation, it promised a totals field in the response object but played coy about how to actually ask for it.

    Take a look at what I got back from GA4 – not a single sign of the totals field. And look at my GA3 response – the totals field is right there, waving at me!

    So, yeah, I would really appreciate if any of you could shed some light on this. Thanks a ton!”

    Daniel replied 1 year ago 3 Members · 2 Replies
  • 2 Replies
  • Mason

    Member
    11 October 2022 at 7:39 am

    Hey, no worries. Just a quick little tweak needed here. You’ll just have to add ‘TOTAL’ to the metricAggregations list in your request. Once you do that, you should start seeing the totals field in your response. Here is a link to the spot in the GA4 documentation that talks about it: [GA4 docs link](https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport#:~:text=see%20Pagination.-,metricAggregations,-%5B%5D). Hope that helps out, mate! Let me know how it goes.

  • Daniel

    Member
    18 February 2023 at 9:16 am

    It seems you’re having some difficulty obtaining the total field from the GA4 API, despite it being easier to do so in GA3. The first thing to do is to ensure that the metrics you’re requesting support the total field. Not all metrics do, so it’s worth checking the GA4 documentation. There may be specific requests needed to pull the total field in GA4. Moreover, double-check syntax and structure of your API call as a slight error can cause data not being pulled correctly. If you still encountered issues, consider reaching out to Google’s support service or engage with the developer communities online to get advice.

Log in to reply.