Using Angular and Google Analytics

By default, Angular does not work very well with Google Analytics. It will only announce a page-view event when refreshing the page. This makes the router in Angular somewhat useless. Luckily, there is an npm package called angular-gtag that hooks into the root app component of your Angular project and sends views upon router navigation. However, I found that the README had a few implicit steps that I needed to do some searching for....

April 18, 2020 · 2 min · Charles M. Knox

How to Fix Angular Not Scrolling to Top for Routerlinks

By default, when using Angular routerLink tags in your HTML, the behavior users will experience when clicking these links is that the browser keeps the current scrollbar positions, before and after clicking. There are cases where this is undesirable, such as when using an Angular router to route URLs (such as /home or /articles ) to Angular components. To fix this, add in your app-routing.module.ts file the following into the @NgModule imports:...

April 17, 2020 · 1 min · Charles M. Knox