-
Consolidating Multiple Google Tag Custom Events into a Single Request
So, I’m tinkering around with GA4, tracking user views of products on this e-commerce site I’m working on. I’m using this fancy piece of code here:
window.gtag('event', 'offer_view', { 'offer_id': offer_id });
Then I get all the juicy stats by picking up the event counts for each product ID using Google Analytics data API:
{ "dateRanges": [ { "startDate": "2023-04-01" "endDate": "2023-05-01" } ], "metrics": [ { "name": "eventCount" } ], "dimensions": [ { "name": "customEvent:offer_id" } ], "dimensionFilter": { "filter": { "fieldName": "customEvent:offer_id", "inListFilter": { "values": [ "75", "76", "37" ] } } } }
All’s well that ends well… but does it end well? My users are browsing around, potentially viewing heaps of products, and that’s sending heaps of requests client-side – not cool.
Any bright ideas on if there’s a way to bundle these same events together and send all the product IDs in one go? I did try sending an array, but as you’d expect, the product ID shows up as an array. Got any tips or tricks for me? Cheers!
Log in to reply.