Learn business growth with Google Analytics 4 Forums Google Analytics 4 Discrepancy between Google Analytics API and web UI data count

  • Discrepancy between Google Analytics API and web UI data count

    Posted by Minh on 14 June 2022 at 9:56 pm

    Hey, I’m wrestling with a bit of a numbers quandary here. So, there’s roughly 35k entries on the web UI that I download as a CSV file, right? But when I check the count, it’s showing me only 600 or so. Something’s off.

    Anyway, here’s the code I’ve been using.

    dimensions = ["sessionSource","customEvent:order_id","date","platform"]
    metrics =  ['sessions']
    request = {
      "requests": [
        {
          "dateRanges": [
            {
              "startDate": "2022-10-15",
              "endDate": "2022-10-17"
            }
          ],
          "dimensions": [{'name': name} for name in dimensions],
          "metrics": [{'name': name} for name in metrics],
          "limit": 10,
          "return_property_quota": True,
          "keep_empty_rows": True,
          "data_loss_from_other_row": False
        }
      ]
    }
    analytics = build('analyticsdata', 'v1beta', credentials=credentials)
    response = analytics.properties().batchRunReports(property=property_id, 
    body=request).execute()
    report_data = defaultdict(list)
    
    Minh replied 10 months, 3 weeks ago 2 Members · 2 Replies
  • 2 Replies
  • Blair

    Member
    2 September 2022 at 11:54 am

    Yeah, it’s just that you’ve set your ‘limit’ to 10 in your query. This simply means your response will contain only 10 rows. So, you might want to tweak that a bit!

  • Minh

    Member
    26 June 2023 at 1:12 pm

    It looks like your Google Analytics API request is only fetching ten rows of data because you set the “limit” parameter to 10 in the request. If you’re trying to get a lot more rows, like the 35,000 you mentioned, you’ll want to increase that limit. Keep in mind, the API might have its own maximum limit that could be less than 35,000.

Log in to reply.