Esta página aún no está traducida al español, así que la mostramos en inglés.

GA4 Event Code Generator — gtag, dataLayer and Measurement Protocol

Pick a recommended GA4 event — generate_lead, sign_up, purchase, add_to_cart and more — or name your own, fill in the parameters and items, and copy the code as gtag(), a Tag Manager dataLayer.push() or a server-side Measurement Protocol request. Names and values are checked against GA4’s limits as you type.

Actualizado el

Items

Tus datos nunca salen de tu ordenador. Todo se procesa localmente en tu navegador.

Cómo usar: GA4 Event Code Generator

  1. Pick a recommended event to get its standard parameters, or choose Custom event and type a name like newsletter_signup.
  2. Fill in or add parameters; ecommerce events also get an Items list with add and remove buttons.
  3. Choose the format: gtag() for sites with the Google tag, dataLayer for Tag Manager, or Measurement Protocol for server-side events.
  4. Optionally wrap it in a click or form-submit listener, copy it, and check the event in GA4 DebugView.

Recommended events vs custom events

GA4 understands recommended events — such as generate_lead, sign_up, login, search and the ecommerce set from view_item to purchase — and fills its built-in reports with them. Use them whenever one fits. For anything else, a custom event works the same way; register its parameters as custom dimensions in Admin → Custom definitions to see them in reports.

The checks it runs

  • Event and parameter names: start with a letter, only letters, numbers and underscores, at most 40 characters, and no reserved prefixes (google_, ga_, firebase_) or reserved event names.
  • At most 25 parameters per event, and parameter values up to 100 characters.
  • Ecommerce: value needs a currency, purchase needs a unique transaction_id, and each item needs an item_id or item_name.

Three ways to send it

gtag() sends straight to GA4. With Tag Manager, dataLayer.push() hands the event to the container, where a Custom Event trigger and a GA4 event tag forward it — ecommerce pushes are preceded by { ecommerce: null } so old items don’t leak into the next event. The Measurement Protocol sends events from your server, for things that happen off the page, like a renewed subscription or an offline sale. To track clicks without writing code per button, use the Event Tracking Script Generator.

También se busca como: ga4 event generator, gtag event code, ga4 event code, ga4 custom event, ga4 recommended events, ga4 ecommerce code, gtag purchase event, ga4 generate_lead.

Herramientas que combinan con: GA4 Event Code Generator

  • Google Tag Snippet Generator — Enter your GA4 measurement ID, Google Ads ID or Tag Manager container ID and get install code that is ready to paste — with Consent Mode v2 defaults, cross-domain linking, debug mode, manual page views and cookie settings switched on only when you need them.
  • dataLayer Push Generator — Build dataLayer.push() code for Google Tag Manager: choose a GA4 recommended event or your own, add parameters and ecommerce items, and optionally wrap it in a click or form submit listener — ready to paste.
  • GA4 Request Decoder — Debug Google Analytics 4 without guesswork.
  • UTM Builder — Add utm_source, utm_medium, utm_campaign and friends to any link, see which GA4 channel the visit will land in, and tag a whole list of URLs at once.

Preguntas frecuentes

How do I send a custom event to GA4?
Call gtag('event', 'your_event_name', { param: 'value' }) after the Google tag has loaded. Choose Custom event here, type the name and parameters, and copy the code.
Why don’t my event parameters show in reports?
Custom parameters only appear in standard reports after you register them in Admin → Custom definitions. Data from before registration is not filled in.
What is the difference between gtag and dataLayer.push?
gtag() is a small wrapper that pushes to the dataLayer for the Google tag. With Tag Manager you push plain objects with an event key, and triggers in the container decide what happens.
Do Measurement Protocol events need a client ID?
Yes. Use the client_id from the visitor’s _ga cookie to join server events to their web session, or your own stable ID for events with no web visit.
¿Puedo instalar GA4 Event Code Generator como aplicación web y utilizarla sin conexión?
Sí. GA4 Event Code Generator es una aplicación web instalable (PWA): se instala desde el navegador, no se descarga desde una tienda de aplicaciones. Haz clic en «Instalar aplicación» en la parte superior de esta página en Chrome o Edge (Windows, macOS, Linux, ChromeOS) o, en Android, utiliza «Compartir» → «Añadir a la pantalla de inicio» en iPhone y iPad, o «Archivo» → «Añadir al Dock» en Safari 17+ en un Mac. A continuación, se abrirá en su propia ventana con su propio icono y, como se ejecuta íntegramente en tu navegador, seguirá funcionando sin conexión. Firefox en el ordenador de sobremesa no permite instalar aplicaciones web. Cómo funciona la instalación.

Herramientas relacionadas