I've built dozens of Angular apps over the last 10 years, and despite GA4 being the worst Google Analytics has ever been, I still use it. I updated from ga to gtag and I've been trying to teach developers how to do this successfully the whole time.

But tonight I discovered that I was wrong.

This code has been a standard part of my library since 2016:

router.events.pipe(filter((e) => e instanceof NavigationEnd)).subscribe((n: NavigationEnd) => {
     gtag('config', 'G-MYPROPERTY', { page_path: n.urlAfterRedirects });
});

But I just discovered that gtag and the recent version of Google analytics tracks history changes automatically.

So what now?

Basically, delete that gtag config call. In gtag we trust.

A tiny warning

While this is default behavior, router tracking now depends on that GA admin setting. If "Page changes based on browser history events" is ever turned off, in-app navigation would stop being counted.