I'm implementing Analytics in a new project and it seems to have changed.

Now they have this Data Stream properties, where you collect a bunch of data automatically.



My project is a Single Page App. The way I used to handle it with an Universal Tag was:

Every time my App renders a new page, I would call gtag("config") to se

nd a new page view.


<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX"></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

On every page change, I call this function:

export function sendPageView(pagePath,pageTitle) {
  gtag("config", "UA_TAG", { 
    page_path: pagePath,
    page_title: pageTitle

If I don't do this, my app would only send the 1st page view, but not subsequent page views, given that fact that my page is not re-loaded, because it's a single page app.

But now, on Google Analytics 4 Data Streams, we get this:

enter image description here

Does it mean that it will send a page view every time the browser history gets a new page? So does it mean I won't need to call gtag over and over again? Has anyone tested it yet?

If this is true, this is good, but also bad, since you can't control the exact time that the page view event will be sent. So if you a page that gathers async data before fully loading, the event will most likely not contain the correct page title, for example.

Has anybody implemented Google Analytics 4 data streams for a Single Page App? How does it work?

1 Answer 1


I've found some more info about this topic.

This is the docs related to the Google Analytics 4 and gtag implementation.


And this is the enhanced measurements doc:


enter image description here

From the image, above, we can see that it will listen for history.pushState() events and send page views based on that. But this is an opt-in feature as you can see:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.