GA4 Advanced Tag with event data

Hi there,

I am trying to use GA4 Advanced Tag and its beta feature ( event data ) to send events to GA4. We added a data-client with a webhook URL and sending the hits to this endpoint from our website. We included the required client_id , session_id session_number etc. Then we trigger this GA4 Advanced Tag by a trigger from our webhook call.

Our webhook payload has the client_id , session_id and session_number parameters along with eventnames etc and in server side preview I can see that it receives the hit to webook and then makes a request to https://www.google-analytics.com/g/collect?xxxx with the parameters attached.

The issue is I can not see the event in GA4 reports. I enabled the debug_mode=true and still can not see the event in GA4 debug view as well.

Since this is a server to server communication I guess it should be using measurement protocol. And the state documentation states that this tag is compatible with Google Analytics 4 Measurement Protocol, I wonder what this means? I mean shall I also include the api_secret in the tag parameters somewhere to make it work?

The events that we are trying to send are happening after the user finishes their journey and it is kind of an admin triggered events, so our aim is to fire those events by using webhooks and stape server side.

What am I missing here?

1 Like

From the description it is difficult to understand what exactly is wrong with your setup, I can assume that perhaps you do not send some mandatory parameters for the event or send them incorrectly.
If you are sending your events from your backend and it is only needed for GA4 then in general there is no point in using sGTM here between this and you can send data directly to GA4 using MP:

We plan to send this to other platforms as well ( Like META CAPI ), that’s why we are trying to use webhook method. We do send client_id, session_id, session_number, and eventname as well.
Here is what I see on sGTM preview that is outgoing to GA4 :
https://www.google-analytics.com/g/collect?cid=xxxx.xxxxx&en=purchase&ep.transaction_id=12345&cu=USDT&uid12345&sid=xxxxx&sct=2&uamb=0&uaw=0&tid=G-xxxxx&_uip=%253A%253A&epn.value=100.38&ep.debug_mode=true&_dbg=1

I guess GA4 needs more parameters to accept the event?

And what does it mean that GA4 Advanced tag is compatible with measurement protocol?

I can assume that it is because of the absence of ‘v=2’ in the query. You can refer to the structure of online hits that are sent:

https://www.google-analytics.com/g/collect?v=2&tid=G-XXXXX&_p=1736854361769&_dbg=1&_geo=1&_rdi=1&npa=0

Also there should be the ‘_dbg=1’ parameter to get into debug mode GA4.
In your case debug_mode=true is just sent as event param

The _dbg was already there, I added the v=2 as well and I can see it in the request URL, but no chance. I mean nothing on GA4 debug view, will wait sometime , maybe it will appear on reports.

@Arif_Senol Did u resolve problem? Im doing same stuff and im struggle with same problem, basic ga4 tag wont recive session_id, and advanced tag form Stape not showing up

Hello!

For the hit to be valid, it must have the v=2 as a query parameter.
If you are using a webhook to sGTM to trigger the tag, then you should create a transformation that adds the x-ga-protocol_version to the Event Data, and attach it to this GA4 Advanced Tag type or to the tags themselves.

As for displaying in the Debug View, the hit must have the Debug Mode parameters (_dbg), along with the _seg (Session Engaged) or _et (Engagement Time) parameters.
Note that this does not mean the hit won’t be processed; it’s just not going to be displayed in the Debug View.
However, it will be available in the Real-Time reports, BigQuery, and later in the processed reports.
You can also add them using Transformations: debug_mode, x-ga-mp2-seg (Session Engaged) and engagement_time_msec (Engagement Time).

An example of Transformation would be this one below.
You can either add both x-ga-mp2-seg (Session Engaged) and engagement_time_msec, or just one of them. Keep in mind that this might affect some calculations, like: Engaged Sessions and Engagement Time.
You can remove the debug_mode parameter after testing, or even create a variable that returns true when sGTM is in Preview Mode, and undefined otherwise.

2 Likes

Thanks you gonna test this one.

Still, no api secret there in transformation or in Advanced GA4. So the only way to send MP hit to GA4 is to use “http request”?

Hi @krystian648.

I didn’t quite understand what your scenario is and what you’re trying to achieve. Could you describe it, please?

Sorry,
I want to send purchase event to ga4 by MP from sGTM.
If event isnt tracked normaly, im using webhook + add cookies previusly saved in stape store. Then send it to fb (easy part) , google ads offline conversion (medium part) and to ga4 (hard part becuase i want atributtion) now im using http request.
**{
“client_id”: “{{Stape Lookup client_id}}”,
“non_personalized_ads”: false,
“events”: [
{
“name”: “purchase_hit3”,
“params”: {
“transaction_id”: “{{ed - ecommerce.transaction_id}}”,
“session_id”: “{{Stape Lookup session_id}}”,
“currency”: “{{ed - ecommerce.currency}}”,
“identyfikator_transkacji”: {{ed - ecommerce.transaction_id}},
“value”: {{ed - ecommerce.value}},
“engagement_time_msec”: 1,
“items”: {{Json - items_array}}
}
}
]
}
**

and its working fine with atribution. But i wonder if there’s any custom template to send MP hit. Your screen dosnt cointans api secret, soo hit wont work

Got you.

I’m not aware of any templates specifically for MP. The HTTP Request built-in template is an option.

Our template does not use MP, it uses the same protocol used by the GA4 tag (which is not the MP and is not documented by Google).