-
How to retrieve item positions for a product using the GA4 API?
Hey there! I’m in the middle of moving some code from UA to GA4 and I’ve hit a bit of a roadblock with migrating a query.
So, I had this query to the UA API where I could feed in a product id, and it’d give me details for each day and each position the product made it onto a list – including how many times it showed. This is the query I used, and it was doing its job perfectly:
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3AXXXXXX&dimensions=ga%3Adate%2Cga%3AproductListPosition&metrics=ga%3AproductListClicks%2Cga%3AproductListViews&filters=ga%3AproductSku%3D%3DP-2375&start-date=7daysAgo&end-date=yesterday
Now, it seems like I’ve hit a wall trying to mirror this in GA4. Here’s what I’ve currently got:
{ "dimensions": [ { "name": "date" }, { "name": "itemListPosition" } ], "metrics": [ { "name": "itemListViewEvents" } ], "dateRanges": [ { "startDate": "2023-05-20", "endDate": "2023-05-26" } ] }
The problem is, GA4 Query Explorer is throwing me this error:
Please remove itemListClickEvents to make the request compatible. The
request’s dimensions & metrics are incompatible. If you need more info, check out
https://ga-dev-tools.web.app/ga4/dimensions-metrics-explorer/So, I’m stuck. What metrics or dimensions should I be using instead? Any advice would be greatly appreciated!
Log in to reply.