Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

280
Views
How to setup custom event tracking with new Google Analytics (GA4) on the server?

I would like to send event data to Google analytics 4 to track conversions on my web app. I found this article: https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=gtag#send_an_event

First I made a custom event that looks like this: Custom event

I created an api secret and included my measurement_id.

I then tried sending data to GA4 with the example in the article:

  const measurement_id = `G-XXXXXXXXX`;
  const api_secret = `XXXXXXXXXXXXXXXXXXXXXX`;

  await fetch(
    `https://www.google-analytics.com/mp/collect?measurement_id=${measurement_id}&api_secret=${api_secret}`,
    {
      method: "POST",
      headers: {
        "User-Agent":
          "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        client_id: "123.123333",
        events: [
          {
            name: "conversion",
            params: { succes: true },
          },
        ],
      }),
    }
  );

I cannot get this to work. Does anyone have experience with this or done something similar that can shine some light on what is going wrong here?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It takes between 34 - 48 hours for data to be shown in the standard reports on google analytics web app. This is due to data processing latency.

If its a new google analytics account it can take up to 72 hours for it to begin displaying data.

The best way to test your requests its to look at the real-time report. it will show if its getting hits almost instantly.

about 4 years ago · Juan Pablo Isaza Report

0

To create a Google Analytics 4 Event tag:

  1. Click Tags > New.
  2. Click Tag Configuration.
  3. Select Google Analytics: GA4 Event.
  4. For Configuration Tag, select the Configuration Tag you created earlier.
  5. For Event Name, specify the name of the event. Use the recommended event names for best results.
  6. Optional: Enter Event Parameters. Use recommended event parameter names for best results.
    1. Click Add Row.
    2. Enter a Parameter Name.
    3. Enter a Value.
  7. Repeat until all desired parameters have been added. Optional: Add any custom user properties that you'd like to configure in User Properties. Note: Analytics automatically logs some user properties. You can set up to 25 additional user properties per Google Analytics 4 property.
  8. Click Triggering and select appropriate events that would cause the tag to fire.
  9. Save the tag configuration and publish your container.
const measurementId = `G-XXXXXXXXXX`;
const apiSecret = `<secret_value>`;

fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${measurementId}&api_secret=${apiSecret}`, {
  method: "POST",
  body: JSON.stringify({
    "client_id": "client_id",
    "events": [{
      "name": "generate_lead",
      "params": {
        "currency": "USD",
        "value": 99.99
      }
    }]
  })
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!