Posts

Showing posts from November, 2022

Blazor with Google Analytics

Image
This is not a post about how to use Google analytics. There are hundreds of books and thousands of articles on that subject. I am going to explain my experience of implementing Google analytics into a Blazor Server application and a Blazor Web Assembly application. The applications are remarkably similar, but there are slight differences that I will point out. I have implemented Google analytics with HTML/CSS/JavaScript applications in the past. It is straight forward implementation; you place a script on your pages to trigger the events you are interested in tracking. On the main page of the application, you add a script and your Google key to associate the events to your account. Since a Blazor application is a SPA, Single Page Application, it is a little more involved to set the trigger points in order to log the analytics. Lucky for use there is a NuGet package that will help us with the heavy lifting. NuGet Package The package is Blazor-Analytics. It is popular. It adds a componen...