BlazorUniversalAnalytics 1.0.3

There is a newer version of this package available.
See the version list below for details.
Install-Package BlazorUniversalAnalytics -Version 1.0.3
dotnet add package BlazorUniversalAnalytics --version 1.0.3
<PackageReference Include="BlazorUniversalAnalytics" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorUniversalAnalytics --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BlazorUniversalAnalytics, 1.0.3"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlazorUniversalAnalytics as a Cake Addin
#addin nuget:?package=BlazorUniversalAnalytics&version=1.0.3

// Install BlazorUniversalAnalytics as a Cake Tool
#tool nuget:?package=BlazorUniversalAnalytics&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Blazor extensions for Analytics. Supported platforms: Google Analytics, GTAG, GTM and Facebook Pixel. AspNetCore Version: 5.0

NuGet Package

GitHub Repository


For Every Tracker

First, import the namespaces in _Imports.razor

@using BlazorUniversalAnalytics
@using BlazorUniversalAnalytics.BUA

Then, add the BUANavigationTracker component below your Router in App.razor.<br/> The tracker listens to every navigation change while it's rendered on a page.

    <Router ... />
+   <BUANavigationTracker />

Setting up Analytics

Inside your main Startup/Program, call AddBUA. This will configure your GTAG_ID automatically.

+   builder.Services.AddBUA("YOUR_GTAG_ID", "YOUR_FBPIXEL_ID", null);

If YOUR_GTM_ID is set, YOUR_GTAG_ID and YOUR_FBPIXEL_ID will be ignored as GTM will manage this for you. Pageview events will be heard if the embed of such scripts exists. Example:

    builder.Services.AddBUA(null, null, "YOUR_GTM_ID");

How to trigger an Analytics Event

See below an example:

@page "/counter"
@using Demo.Shared


<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
    private int currentCount = 0;

    protected IBUA Analytics { get; set; }

    private WeatherForecast SampleData = new WeatherForecast
        Date = DateTime.Now,
        TemperatureC = 30,
        Summary = "It's a hot day"

    private void IncrementCount()

        // IMPORTANT: The object SampleDate are used below just as an example.
        // You must to check the correct object properties on respective Analytic tool you are using.

        // Google Analytics
        //Analytics.TrackEventGtag("event-name", "event-value", "event-category", "event-label");
        //Analytics.TrackEventGtag("event-name", SampleData);

        // Facebook
        //Analytics.TrackEventFacebookPixel("event-name", SampleData);

        // Google Tag Manager
        //Analytics.TrackEventGTM("event-name", SampleData);

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 121 11/12/2021
1.0.3 270 2/3/2021