-
What are the updated methods for batching POST requests in GA4?
Hey there! So, I’ve been in the trenches migrating our setup from Universal Analytics over to GA4. Right now, we’re working magic on the server side with Node.js to bring users’ IP addresses to their simplest form and sending our data in batches. We’re doing it this way so we can keep our users’ info under wraps by only sending data after a certain amount of time has passed and we have a mixed bag of different users.
Doing a deep dive, I found out that the ‘/batch’ endpoint from our old friend Wreck has been given the boot in GA4. I’m just hanging in the breeze here, trying to track down a new endpoint to do the batching, but having a tough go at it. Although, on the upside, I had a win with sending a single event :
`javascript
wreck
.request(‘post’, ‘https://www.google-analytics.com/mp/collect?&measurement_id=’, {
agent: this._agent,
payload: {
client_id: ‘1234’,
user_id: ‘4321’,
events: [
{
name: ‘test’,
params: {
page_view: ‘True’
}
}
]
},
timeout: 0
})
`
I’ve been hitting the books, thumbing through the GA documentation and everything, but I’m still missing the puzzle piece on finding the right method or endpoint. Anyone out there had luck yet?We might just give up the ghost on this approach and fall back on Google’s backup gtag method found here https://developers.google.com/tag-platform/tag-manager/server-side. But I gotta say, it sort of feels like I’ve been training for a marathon only to hitch a ride halfway (aka, my attempts have been in vain).
I’ve been testing out a ton of endpoints from https://developers.google.com/analytics/devguides/reporting/data/v1/rest – but no dice. It’s like the realtime event has gone AWOL. Any suggestions?
Log in to reply.