1

I recently started using GA4 with measurement protocol api. I have an issue, that doesn't matter how many events, custom or automatic ones I send, they don't appear in standard reports.

enter image description here

I see users in user explorer though: enter image description here

JS code that I used to send events to api:

fetch(
  `https://www.google-analytics.com/mp/collect?measurement_id=${measurement_id}&api_secret=${api_secret}`,
  {
    method: 'POST',
    body: {
      client_id: clientId,
      user_id: userId,
      events: [
         {
           name: 'first_visit',
           params: {},
         },
         {
           name: 'session_start',
           params: {},
         },
         {
           name: 'custom_event',
           params: {},
         },
      ],
      user_properties: {},
    },
  },
)

I know that GA takes a while to aggregate data, but I waited for 4 days and it still shows 0 everywhere.

Am I missing something? Maybe I need to send a specific event so that GA4 aggregates it? Or am I missing some sort of parameter in the request? Maybe I need to configure something in the project itself?

Any help would be very appreciated.

oguz ismail
  • 1
  • 16
  • 47
  • 69
R. Vait
  • 918
  • 2
  • 7
  • 20

1 Answers1

-1

try using JSON body

https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=firebase https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#purchase

body: JSON.stringify({
    app_instance_id: 'app_instance_id',
    events: [{
      name: 'tutorial_begin',
      params: {},
    }]
  })
Hans
  • 61
  • 10