4

[Edited. Added code sample and more explanations]

Is anybody familiar with the GA4 Measurement Protocol?

We are sending events from our backend servers to the server-side GTM container using the GA4 Measurement Protocol. Everything works fine except for conversion tracking. The events marked as conversion are not counted as conversions if we send those via MP (except for the default "purchase" event, it works perfectly). The same event with the same parameters counts as a conversion if we send it from the browser (client-side GTM). As I couldn't find anything about this issue online, the only thing left was to debug parameter by parameter using the server-side GTM preview mode. Here I discovered, that if I send events from the browser, the requests for events I mark as conversions in GA have "&_c=1" in their query string.

That means, as far as I understand it, that in order to get conversion events via MP, the event request needs to have "_c" query string parameter. I tried adding "_c" as an event param, but that didn't work. Is there a designated JSON parameter to mark the event as a conversion?

------------MORE INFO--------------

Here is an example of an event "Experts". This event gets sent from both the client-side and the server. As you can see in the screenshot, this event is marked as a conversion.

"Configure > Conversions" page

As you can see on the second screenshot, the actual events (137) are much more than the conversions detected (48). The difference are exactly the ones sent from the server-side.

"Configure > Events" page

Here is the request body of the server call:

    {
    "client_id":"Z9TLWnyVC2UK4UssPIVk8J+2n5BZhgWLtWSlFYYSwlg=.1642076344",
    "user_id":"119412",
    "events": [{
        "name": "Experts",
        "params": {
            "tenweb_action": "[Test action]",
            "tenweb_info": "[Some more info]",
            "debug_mode":1,
            "page_location": "https://10web.io/[some-test-page]"
            
            }
          }]
      }
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Can you show the code you are using from the https://developers.google.com/analytics/devguides/collection/protocol/ga4 and describe your issues. Show what you want to send what you cant send, what does get sent and what it registers or what it should register. Ga4 measurement protocol does not allow for sending all of the events that the standard google supplied sdks and snippets do. They have some of them locked out for us. The more people i get to document the issues the more changes i have of getting them to open up more. – Linda Lawton - DaImTo Apr 29 '22 at 11:10
  • Hi @DaImTo, thx for the comment. I added screenshots and a sample event request payload. The events are sent and registered without any issues. All parameters are registered correctly. The events are attributed to the correct user, shown both in Real-time and other reports. The ONLY problem is that the "Mark as conversion" switch applies to the client-side events, and not the server-sent ones. There is no way to mark server-side events as conversions. – Armen Saghatelian Apr 30 '22 at 16:32
  • @DaImTo one more addition. The default "purchase" event, that is "Marked as conversion" by default, registers as a conversion without any additional config (also sent using MP with the same format), so I suppose it may be just a bug of GA4, that manually "Marked" conversion events do not apply to MP events. Alternative solution would be adding a param, e.g. `events.params.conversion=true` , to the request, but I couldn't find such a parameter anywhere. – Armen Saghatelian Apr 30 '22 at 16:52
  • These checkboxes are changing the way how the gtag.js is generated. In case conversion event is registered, an additional parameter _c=1 is sent with the event. If the purpose of this checkbox should tell GA to process such events differently, why they would generate the conversion event detection logic for gtag? My hypothesis is it that you have to send an additional parameter along with the event. What it is I do not know. – Jan May 02 '22 at 15:23
  • @Jan that's exactly what I think too. The problem is that I don't know how to add `_c=1` to the measurement protocol request. – Armen Saghatelian May 03 '22 at 07:43
  • @armen-saghatelian I was playing with it and was able to make it work by adding the _c=true as the search parameter into the uri by mimicking the gtag functionality. Still POST request, but no payload. As this is unofficial hack, it is uncertain whether it will work in the future. – Jan May 04 '22 at 10:17
  • 1
    @Jan this is genius :))) This hack really works if I send requests directly to GA. The problem with this solution, apart from being an unofficial hack, that might not work tomorrow, is that we use the GTM server-side container, and it loses the _c=true parameter in GTM. But, as I mentioned, it works if I skip the GTM SS container and send the event directly to GA. If I don't find any better solution, I might use this hack. Thank you – Armen Saghatelian May 04 '22 at 14:01

1 Answers1

2

@Jan, @DaImTo, and everyone else that might have this issue in the future.

I think I've found a solution. Although it's unofficial and might break at any moment, it's the best one I've found so far. Here is what I ended up doing. While debugging via GTM preview mode I noticed, that in Event Data tab of conversion events there is an object "x-ga-system_properties", that, among other system variables, contains c:"1" . So I tried adding

            "x-ga-system_properties":{"c":"1"}

to the event parameters JSON that we send to the Measurement Protocol endpoint of our server-side GTM.

IT WORKED. The events sent that way were registered as conversions by GA4.

Would be great to hear your thoughts on this. Do you think it's a stable solution? Do you think there will be official documentation on this from Google?