Learn business growth with Google Analytics 4 Forums Google Analytics 4 Enhancing AB Testing Reporting in GA4 Data API

  • Enhancing AB Testing Reporting in GA4 Data API

    Posted by Taylor on 21 December 2022 at 7:13 pm

    Alright folks, let me lay down the situation. I’m trying to put together this cool setup in GA4 revolving around AB Testing without diving into the deep end of user_scope dimensions and those tricky swimlanes.

    Currently I’ve got gtag('event', 'experiment', { exp_bucket }); being fired and configured as an event dimension. Pretty neat, I can gaze upon this data in all its glory in the Custom Explore UI. However, problem arises when I try to recreate this User segment or even another view in the GA4 Beta Data API. I end up getting a good for nothing set of User Totals, Event Counts and 0’s for funnel steps! Like, what the?

    
    makeRequest(https://analyticsdata.googleapis.com/v1beta/properties/<span class="hljs-subst">${propertyId}</span>:runReport, {
        dateRanges: [{ startDate: '2023-03-20', endDate: 'today' }],
        dimensions: [{ name: customEvent:exp_bucket }],
        metrics: [
          { name: 'totalUsers' },
          { name: 'newUsers' },
          { name: 'bounceRate' },
          { name: 'addToCarts' },
          { name: 'checkouts' },
          { name: 'totalRevenue' },
          { name: 'totalPurchasers' },
          { name: 'ecommercePurchases' },
          { name: 'firstTimePurchaserConversionRate' },
          { name: 'averagePurchaseRevenuePerPayingUser' },
        ],
      });
    

    Below is snapshot of what I mean – note the event scoped dimension report.

    event scoped dimension report

    Now the burning question is, can I adjust my data pull? Or possibly consider changing something in the event or dimension architecture? Currently, I’m thinking of creating like “ab_test_lane_[1|2|3|4|5]” as a user dimension and mapping each active experiment into a lane. But then, I’ve got the headache caused by the complexity of mapping live experiments to solitary lanes to ward off any conflicts. Any ideas guys?

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

    Member
    7 June 2023 at 7:43 am

    The issue you’re encountering seems to originate from the event scope of your dimension. When mapping certain types of data in GA4, specifically involving metrics and dimensions, it’s crucial to understand their scopes. User (or broader) scoped variables can encompass the data from event scoped ones but not vice versa. Therefore, when you pull in data from the API, concepts like ‘totalUsers’, ‘newUsers’, etc., which are user-scoped, can’t be correctly captured under an event-scoped dimension such as your ‘exp_bucket’. Your concept of using ‘ab_test_lane_[1|2|3|4|5]’ as a user dimension might help you bypass this scope conflict. However, you’d indeed need to manage the complexity of mapping live experiments to these lanes carefully to avoid inconsistencies in the data.

  • Thomas

    Member
    12 June 2023 at 12:50 pm

    When using event-scoped dimensions, as in your case with exp_bucket, Google Analytics 4 executes queries at the event level rather than user level. This difference would explain why your user-total and funnel step data appears as 0.

    A possible solution could be to redefine your dimensions as user-scoped. This can be achieved by storing the exp_bucket value in a user property when the experiment event is fired. Then, you can use this user property as the dimension in your reports, which would be a workaround for your current issue with user totals returning as zero.

    Another way to handle this is by redefining your data pull to accommodate a user-level analysis. That means changing your dimensions attribute to something like dimensions: [{ name: 'userPseudoId' }], and then grouping by the exp_bucket column in your results.

    Remember that it’s important to use the appropriate scope (event or user) for your analysis as both have somewhat different use cases. User-scoped dimensions would be more suitable for cumulative data across all the user sessions, while event-scoped dimensions would be more appropriate for data related to individual sessions or page views.

    Regarding the idea of creating “ab_test_lane_[1|2|3|4|5]”, consider the scale of your implementation. If you have enough lanes that mapping won’t be an issue and the experiment configurations don’t overlap, this could work. However, you’ll need to ensure that all future experiments are carefully mapped to the correct lane to avoid conflict, which could be a complex and error-prone task.

Log in to reply.