Learn business growth with Google Analytics 4 Forums Google Analytics 4 How to retrieve item positions for a product using the GA4 API?

  • How to retrieve item positions for a product using the GA4 API?

    Posted by Hannah on 6 May 2023 at 5:16 pm

    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!

    Mia replied 1 year, 4 months ago 3 Members · 2 Replies
  • 2 Replies
  • Sawyer

    Member
    19 June 2023 at 2:02 pm

    Looks like the GA4 query isn’t liking “itemListClickEvents” because it’s incompatible with the dimensions you’ve chosen. You could replace it with “item_views” or “product_detail_views” since GA4 uses event-based tracking. Also, GA4 might not directly support list position tracking like UA, so it could require a custom implementation. Worth checking out Google’s official docs or perhaps a Google Analytics expert for more detailed advice!

  • Mia

    Member
    23 June 2023 at 12:19 am

    The error message indicates that the dimension ‘itemListPosition’ and the metric ‘itemListViewEvents’ are incompatible, this means they can’t be used together in the same query. In GA4, not all dimensions and metrics can be queried together, unlike in UA. As the error message suggests, you can look at Google Analytics 4’s Dimensions & Metrics Explorer to understand which dimensions and metrics are compatible. In your case, you might need to separate your queries or find different dimensions or metrics that will give you the data you need. Google also provides a list labeled “Compatibility groups” for each dimension or metric that shows the other dimensions or metrics it can be used with. If different dimensions or metrics do not meet your needs, you may have to implement a custom event or parameter to track the desired data.

Log in to reply.