Sending Webhook to Google Analytics 4 (GA4) Measurement Protocol

Hi there! I’m having some trouble with sending a webhook to the GA4 measurement protocol when triggered by a third-party CRM. The way it should work is that when a webhook trigger receives data, it sends POST to a GA4 endpoint. I used this to verify the validity of the body of my HTML request: Event Builder

I have filled in the correct parameters on that builder and it’s correctly triggering the conversion event in GA4 when tested from there. However, I’m having quite a hard time getting it to work on n8n. I am receiving a silent 204 which, from what I understand, means that something isn’t formatted correctly.

I have a feeling that there must be a fairly simple solution here that I’m totally missing. I’ve tried to find similar questions on here to no avail, although that’s likely because I’m not too sure what the problem is :sweat_smile: I’m novice-intermediate when it comes to my JSON knowledge and I feel like that part is formatted correctly, but I’m not sure if I need to do it differently with n8n.

I would really appreciate any push in the right direction here :slight_smile: As for the workflow, I’ve been trying to just send static data first from this HTTP node:
{
“nodes”: [
{
“parameters”: {
“requestMethod”: “POST”,
“url”: “=https://www.google-analytics.com/mp/collect?api_secret={hidden_for_post}&measurement_id={hidden_for_post}”,
“allowUnauthorizedCerts”: true,
“jsonParameters”: true,
“options”: {
“bodyContentType”: “json”,
“fullResponse”: true
},
“bodyParametersJson”: “={\n “client_id”:”{hidden_for_post}",\n “non_personalized_ads”:false,\n “events”:[\n {\n “name”:“purchase”,\n “params”:{\n “items”:[\n {\n “item_name”:“funding”\n }\n ],\n “currency”:“USD”,\n “transaction_id”:“3642”,\n “value”:5000\n }\n }\n ]\n}",
“headerParametersJson”: “={\n “HOST”:“google-analytics.com”\t\t\t\t\n}”
},
“name”: “HTTP Request”,
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 1,
“position”: [
160,
560
]
}
],
“connections”: {}
}

n8n version:0.172.0 (about to go update now that I realize I’m a bit out of date but I don’t think n8n is the issue here lol)

  • **Database: SQLite
  • **Running n8n with the execution process [own(default), main]:own…I think?
  • **Running n8n via [Docker, npm, n8n.cloud, desktop app]:Docker

Hey @NoblemenAJ, welcome to the community :tada:

I am sorry to hear you’re having trouble here. Unfortunately I am not at all familiar with GA4 so don’t have a working example to share. The status code 204 would, however, indicate a success status, so perhaps this is working as expected? Do you get a different response when sending the request via curl or Postman?

One thing you could try is to send your request to a URL provided by a service like https://webhook.site/. This service would let you inspect the exact request sent by n8n, making it a bit easier to spot what might be missing (when comparing your request with a working example).

That’s what I thought as well! Did some digging online though and buried deep in some documentation somewhere I read that a 204 with the Measurement Protocol means that something is misformatted. Thank you so much for that site, I think that should help me figure this one out. I had it working on Postman, but I wasn’t sure if maybe I misformatted the header or a part of the body when copying it into n8n maybe. I’ll report back here with whatever I sort out! And thanks for the welcome :smiley: n8n has been a game changer for my workflow so far so I’m hoping I can figure this out and contribute to this forum where I’ve found so many answers so far lol