0
votes

I am running the following for our GA reporting v4 API - it works fine without the Ecommerce portion but once I add "ecommerce", it gave me an error.

def get_client_report(analytics):
    return analytics.userActivity().search(
    body=

    {
        "viewId": VIEW_ID,
        "user": {
            "type": "CLIENT_ID",
            "userId": "REDACTED"
        },

        "activityTypes": [
        "ECOMMERCE"
        ],

        "dateRange": {
            "startDate": "2020-04-02",
            "endDate": "2020-04-02"
        },

        "ecommerce": {
            "transaction": {
                  "transactionId" : "REDACTED"
            }
        }
    }
  ).execute()

and I get the following error:

https://analyticsreporting.googleapis.com/v4/userActivity:search?alt=json returned "Invalid JSON payload received. Unknown name "ecommerce": Cannot find field.". Details: "[{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'description': 'Invalid JSON payload received. Unknown name "ecommerce": Cannot find field.'}]}]">

Can you help me what is wrong here? Thank you!

1

1 Answers

0
votes

your request body doesn't match the expected format. Take a closer look at docs. only activityTypes field is supported and you cannot filter for a specific transactions ID. you'll have to perform filtering on your side after receiving a response in that case.