Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

286
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda