Tracking with the new Google Analytics 4 (GA4) server-side


Google Analytics 4 (GA4) was recently released and made the default for new properties on the Google Analytics dashboard. I was checking it out and it looks great. We report a lot of our data to Google Analytics via our Node.js server as opposed to client-side using a library called universal-analytics (, which works very well.

We want to start using GA4 asap but we cannot find any documentation on how to send events to a GA4 property server-side. There are only client-side examples and those don’t seem to work at all on a server.

Simply put, what is the serverside equivalent for the following?

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src=""></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-ABC123ABC123');

Anyone had success with this?


You can try to use measurement protocol v2:

However, it is currently in alpha version.

enter image description here

Answered By – Michele Pisani

Answer Checked By – Clifford M. (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.