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!
3 Answers
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 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
}
}
]
}
-
For completeness sake: `"params": {"x-ga-system_properties": {"dbg": "1"}}` also works – Harm Mar 30 '22 at 11:18
-
1Sorry about that, `x-ga-system_properties` only seems to work if it is going to a server-side GTM container, not directly to GA4 – Harm Apr 04 '22 at 10:03
-
I've been using your above example, and for a long time, I thought it was incorrect or had something wrong because I couldn't see it show in DebugView. Eventually, I checked my actual analytics and saw that the page_view events were showing, so my assumption is DebugView is just buggy. – Mark Pearl Jan 01 '23 at 17:40
-
Apparently there is a caveat: the `client_id` needs to be already known to GA4. See here for more details > https://www.simoahava.com/analytics/debugview-with-ga4-measurement-protocol/ – coccoinomane Jul 13 '23 at 12:53
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:
- Add the
debug_mode: true
field to individual event params as described in @bang's answer - Use the
/debug/mp
endpoint as described in @DalmTo's answer - this pointed me towards the errors in myuser_properties
format
Regarding 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.

- 3,311
- 1
- 24
- 25
The measurment protocol for ga4 has two endpoints just like the measurment protocol for the old Google anlaytics
- Measurement Protocol /mp/collect
- Measurement Protocol Validation Server /debug/mp/collect
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>

- 106,405
- 32
- 180
- 449
-
Yes, that I'm aware of but is not what I'm looking for. I want to append the debug_mode parameter to a request that will cause analyitcs to register the event but filter it to the DebugView. The /debug/mp/collect will only validate the request not register it at all in analytics. Link to the more info about debug_mode: https://support.google.com/analytics/answer/7201382?hl=en – bang Dec 01 '20 at 23:25