Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
How to track events in both Universal Analytics and GA4 at the same time?

I'm currently tracking events in GA4 successfully like so:

Loading script:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ url_escape(google_tag_manager_id) }}"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() { window.dataLayer.push(arguments); }
  gtag('js', new Date());
  gtag('config', {{ json_encode(google_tag_manager_id) }});
</script>

Firing call:

gtag('event', event, payload);

The marketing team also wants to support the old Universal Analytics. From my looking around it seems the way to load the script for that is:

<script type="text/plain" data-cookie-setter>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  (function(w,d) {
  var gaId = 'DEMO';
  var accountType = 'user';
  w.ga('create', gaId, 'auto');
  w.ga('set', 'dimension2', accountType);
  w.ga('send', 'pageview');
  })(window,document);
</script>

And firing events like this:

ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

My questions are:

  1. Is the above the right way to load the Universal Analytics script?
  2. Is the above the right way to fire events for Universal Analytics?
  3. If I fire both events simultaneously will there be any conflicts/bad data? Or will the send events to their respective properties in peace?
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda