'Google analytics Calculated Metric using case when

I am targeted to research whether this is doable:

To create a calculated metric (Order Submit) in google analytics (https://analytics.google.com/). I am using UA (not GA4). So I am going to create it in a view.

Order Submit:

  • Before 2021/12/18: [ga:eventAction] like '%Submit Button Click%'. value should be sum of [ga:uniqueEvents];
  • After 2021/12/18: [ga:eventAction] like ‘%checkout%’ and [ga:eventLabel] like ‘%2%’,value should be sum of [ga:totalEvents];

The ultimate goal is going to use the field via Google analytics API v4 in python. I know how to get the calculated metric via API once it's defined. But I couldn't figure out how to do the case statement for the calculated metric. It looks it can only handle simple operation on existing metrics, e.g. metric 1/ metric 2.

If that's not possible, any workaround?

BTW, I know in google data studio I can possibly create something like that using case statement, but it can not be used in google API v4 I suppose?



Solution 1:[1]

This is not possible with calculated metric. The walkabout is to get all related dimensions and metrics in a table. Then you can calculate by yourself using SQL or whatever language depending on where you stored the data.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 thotwielder