0

I want to build an API to retrieve the Conversion Rates of Purchases via Google Analytics 4. (I understand after reading blogs these are now called 'Key Events')

I am new to GA4 so learning as I go.

I'm using the GA4 Query Explorer to test and build the request:

https://ga-dev-tools.google/ga4/query-explorer/

How do I specifically retrieve the 'Key Event: Purchase' conversion rate? Ideally as a percent but this can be calculated later if not possible?

I've set the parameters like this:

enter image description here

And the response is this:

enter image description here

Am I missing anything? Are those numbers returned just the total purchases for each day? Would it be possible to retrieve the % Conversion Rate for Purchase? I'm guessing I would need to also track all users who visit the checkout page - how would I do this?

2 Answers 2

0

it depends what is your definition of Conversion Rates of Purchases , typically it is purchases / active users , to achieve this you can use date as a dimension and Key Event: Purchase and active users as metrics, then you can divide them in sheets or in the script if you use API directly

0

I got it working with the below JSON POST Request - this the E-Commerce Conversion rate with user scope. Amend the start and end dates to your requirements:

URL:https://analyticsdata.googleapis.com/v1beta/properties/[YOUR PROPERTY NUMBER]:runReport


BODY:


{
    "dimensions": [
        {
            "name": "eventName"
        },
        {
            "name": "firstUserDefaultChannelGroup"
        }
    ],
    "metrics": [
        {
            "name": "ecommercePurchases"
        },
        {
            "name": "totalUsers"
        },
        {
            "name": "userKeyEventRate"
        }
    ],
    "dateRanges": [
        {
            "startDate": "yesterday",
            "endDate": "yesterday"
        }
    ],
    "dimensionFilter": {
        "filter": {
            "fieldName": "eventName",
            "inListFilter": {
                "values": [
                    "session_start",
                    "purchase"
                ]
            }
        }
    },
    "metricAggregations": [
        "TOTAL"
    ]
}

Hopefully this will help someone else.

Not the answer you're looking for? Browse other questions tagged or ask your own question.