Learn business growth with Google Analytics 4 Forums Google Analytics 4 Retrieving GA4 Google Analytics data for dimensions with missing or unset values

  • Retrieving GA4 Google Analytics data for dimensions with missing or unset values

    Posted by Devin on 3 July 2022 at 11:08 am

    So, I noticed a little something with GA4. It seems to toss out any rows where any of my dimensions, including the custom ones, are null. I can’t really afford to lose that data.
    I whipped up a bit of code to illustrate this.

    request = RunReportRequest(
                property=f"properties/{self.property_id}",
                dimensions=dimension_list,
                metrics=metrics_list,
                limit=row_limit,
                return_property_quota=quota_usage,
                date_ranges=[DateRange(start_date="2022-09-27", end_date="2022-10-06")],
                dimension_filter=FilterExpression(
                    filter=Filter(
                                            field_name="customEvent:order_id",
                                            string_filter=Filter.StringFilter(value="8723903"),
                                        )
                                    ),
    keep_empty_rows = True,
                ignore_unknown_fields = True
            )
    
    George replied 1 year, 2 months ago 3 Members · 2 Replies
  • 2 Replies
  • Daniel

    Member
    9 August 2022 at 12:53 pm

    The problem here is that Google Analytics 4 (GA4) is dropping any rows where dimensions, including custom ones, are null. The posted code is an illustration of this problem. The programmer tried to solve it by flagging GA4 to keep rows even when they’re empty (keep_empty_rows = True) and ignore fields it doesn’t recognize (ignore_unknown_fields = True).

  • George

    Member
    13 October 2022 at 10:40 pm

    You are correct in your observation. By default, Google Analytics GA4 omits rows where values of the specified dimensions are null. However, you have incorporated the ‘keep_empty_rows’ argument in your RunReportRequest, and have set it to ‘True’. This should ideally prevent the exclusion of rows with null values. It looks like your code is correct.

    If the problem persists, it may be due to internal GA4 settings or perhaps a bug. You might want to consider contacting GA4’s support team for further assistance. Since the code appears to be correctly asking for rows with null values to be included, the problem is likely rooted elsewhere.

Log in to reply.