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

176
Views
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
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!