Osirion.Blazor.Analytics 2.1.1

dotnet add package Osirion.Blazor.Analytics --version 2.1.1
                    
NuGet\Install-Package Osirion.Blazor.Analytics -Version 2.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Osirion.Blazor.Analytics" Version="2.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Osirion.Blazor.Analytics" Version="2.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Osirion.Blazor.Analytics" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Osirion.Blazor.Analytics --version 2.1.1
                    
#r "nuget: Osirion.Blazor.Analytics, 2.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Osirion.Blazor.Analytics&version=2.1.1
                    
Install Osirion.Blazor.Analytics as a Cake Addin
#tool nuget:?package=Osirion.Blazor.Analytics&version=2.1.1
                    
Install Osirion.Blazor.Analytics as a Cake Tool

Osirion.Blazor.Analytics

NuGet License

Analytics integration for Blazor applications, supporting multiple providers with SSR compatibility.

Features

  • Multiple Providers: Microsoft Clarity and Matomo support out of the box
  • Provider Pattern: Easily extend with your own analytics providers
  • SSR Compatible: Works with Server-Side Rendering and Static SSG
  • Configuration-Driven: Simple setup through dependency injection
  • Privacy-Focused: Opt-in tracking with consent options

Installation

dotnet add package Osirion.Blazor.Analytics

Usage

Quick Start

// In Program.cs
using Osirion.Blazor.Analytics.Extensions;

builder.Services.AddOsirionAnalytics(analytics => {
    analytics
        .AddClarity(options => {
            options.SiteId = "your-clarity-site-id";
        })
        .AddMatomo(options => {
            options.SiteId = "1";
            options.TrackerUrl = "//analytics.example.com/";
        });
});
@using Osirion.Blazor.Analytics.Components


<ClarityTracker />
<MatomoTracker />

With Configuration

// In appsettings.json
{
  "Osirion": {
    "Analytics": {
      "Clarity": {
        "SiteId": "your-clarity-site-id",
        "Enabled": true
      },
      "Matomo": {
        "SiteId": "1",
        "TrackerUrl": "//analytics.example.com/",
        "TrackLinks": true,
        "RequireConsent": false
      }
    }
  }
}
// In Program.cs
builder.Services.AddOsirion(builder.Configuration);

Manual Tracking

@inject IAnalyticsService Analytics

// Track a page view
await Analytics.TrackPageViewAsync("/custom-path");

// Track an event
await Analytics.TrackEventAsync("category", "action", "label", value);

Creating Custom Providers

public class CustomProvider : IAnalyticsProvider
{
    public string ProviderId => "custom";
    public bool IsEnabled => true;
    public bool ShouldRender => true;

    public Task TrackEventAsync(string category, string action, string? label = null, object? value = null, CancellationToken cancellationToken = default)
    {
        // Custom implementation
        return Task.CompletedTask;
    }

    public Task TrackPageViewAsync(string? path = null, CancellationToken cancellationToken = default)
    {
        // Custom implementation
        return Task.CompletedTask;
    }

    public string GetScript()
    {
        return "<script>/* Custom tracking script */</script>";
    }
}

// Register the provider
builder.Services.AddOsirionAnalytics(analytics => {
    analytics.AddProvider<CustomProvider>();
});

Documentation

For more detailed documentation, see Analytics Documentation.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Osirion.Blazor.Analytics:

Package Downloads
Osirion.Blazor

Modern, high-performance Blazor components and utilities. Features SSR-compatible components for navigation, analytics, content management, and theming with seamless CSS framework integration.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.1 133 5/20/2025
2.1.0 132 5/19/2025
2.0.2 156 4/23/2025
2.0.1 152 4/23/2025
2.0.0 155 4/22/2025