Search code examples
google-analyticspostmanhttprequestmeasurement-protocolgoogle-analytics-4

Custom event shows in GA4 realtime when sending MP request from event builder, but not when same request is sent from postman


I'm new to postman and experimenting with sending custom events to my GA4 property via measurement protocol requests. I want to use this for server-side implementations and offline events. Google's official documentation is here and their event builder is here. I've confirmed the event successfully populates in GA4 realtime report.

I'm using the Post method with the URL https://www.google-analytics.com/mp/collect?measurement_id=${{measurement_id}}&api_secret=${{api_secret}} and have also tried adding /debug to the start of the path. When I do, there are no error messages in the response body.

I've double-checked that I have the correct secret and am using the measurement id, not the data stream. I copy-pasted the body from the event builder. The body of my request is:

{
    "client_id": "1192607906.1689072640",
    "events": [{
        {
            "name": "event_test_emma",
            "params": {}
        }
    }]
}

I've tried this as both json and text with the Content-Type request header updated to match.

Regarding headers, I've tried both the default headers and editing/adding headers so they match the request headers from the event builder as closely as possible.

No matter what I try, though, the event doesn't show in the realtime report.


Solution

  • Your JSON have a double {{ for the "events". Your JSON

    {
        "client_id": "1192607906.1689072640",
        "events": [{
            {
                "name": "event_test_emma",
                "params": {}
            }
        }]
    }
    

    The problem

    {
        "client_id": "1192607906.1689072640",
        "events": 
    

    [{ {

                "name": "event_test_emma",
                "params": {}
            
    

    } }]

    }
    

    Fixed JSON

    {
        "client_id": "1192607906.1689072640",
        "events": 
            {
                "name": "event_test_emma",
                "params": {}
            }
        
    }
    

    And your postman should be like this.

    enter image description here

    enter image description here