Can't find a way to set the debug_mode parameter using Measurement Protocol 4 . Tried to put it everywhere (and naming it all i can think of) but without luck:) Documentation is still very light and doesn't mention the debug_mode. With web/js and GA4 it works fine!
To add to the answers of @DalmTo and @bang - I wasn't seeing events I was sending over the Measurement Protocol show up in our GA4 Debug View. The root cause in my case was that the Measurement Protocol expects a funky format for the user_properties
, but the following steps should help others debug other problems as well.
Steps I took to resolve:
debug_mode: true
field to individual event params as described in @bang's answer/debug/mp
endpoint as described in @DalmTo's answer - this pointed me towards the errors in my user_properties
formatRegarding the user_properties
field, I was sending something along these lines:
{
"client_id": "XXX.XXX",
"user_id": "YYY",
"user_properties": {
"property_a": "value_a",
"property_b": "value_b"
},
"events": ...
}
Turns out GA4 / Measurement Protocol expect something like this:
{
"client_id": "XXX.XXX",
"user_id": "YYY",
"user_properties": {
"property_a": { "value": "value_a" },
"property_b": { "value": "value_b" }
},
"events": ...
}
At the time of writing, the only way to figure this out is to carefully check out the example here .
The measurment protocol for ga4 has two endpoints just like the measurment protocol for the old Google anlaytics
So if you send a event to it will be sent to Google anlaytics ga4
POST /mp/collect HTTP/1.1
HOST: www.google-analytics.com
<payload_data>
So if you send a event to it will be sent to debug endpoint for Google anlaytics ga4
POST /debug/mp/collect HTTP/1.1
HOST: www.google-analytics.com
<payload_data>
Weird. Suddenly the debug mode started to work with code I'm 100% sure didn't work before.
Adding the parameter debug_mode = true to the measurement protocol 4 request will make it show up in analytics DebugView.
Sample json payload that works:
{
client_id: 'XXXXXXXXXX.YYYYYYYYYY',
events:
[{
name: 'page_view',
params:
{
page_location: '....',
page_path: '....',
page_title: '....',
debug_mode: true
}
}]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.