Matomo.Blazor 10.0.8

dotnet add package Matomo.Blazor --version 10.0.8
                    
NuGet\Install-Package Matomo.Blazor -Version 10.0.8
                    
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="Matomo.Blazor" Version="10.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Matomo.Blazor" Version="10.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Matomo.Blazor" />
                    
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 Matomo.Blazor --version 10.0.8
                    
#r "nuget: Matomo.Blazor, 10.0.8"
                    
#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.
#:package Matomo.Blazor@10.0.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Matomo.Blazor&version=10.0.8
                    
Install as a Cake Addin
#tool nuget:?package=Matomo.Blazor&version=10.0.8
                    
Install as a Cake Tool

Matomo Blazor

Matomo Blazor is a Blazor component that registers and enables the Matomo Analytics tracking code for you.

This component builds upon the MatomoProvider by igotinfected, enhancing it with support for custom variables and custom dimensions.

Setup

Add the script to the index.html file in the wwwroot folder for WebAssembly projects, or include it in the App.razor file in the Components folder for server app project. This script initializes the Matomo tracking code.

<script src="_content/Matomo.Blazor/matomo.js"></script>

Add the <Matomo /> component to your entry that can be App.razor in WebAssembly or Router.razor in Server. It should be added in the highest level component possible to ensure that it is loaded on every page. Is recommended to use an environment check to load the correct configuration for the component. This is to avoid tracking development data.

@if (!Env.IsDevelopment())
{
<Matomo
        ApiUrl="@_apiUrl"
        SiteId="@_siteId"
        UserIdFunc="() => UserId()"
        CustomVariables="Variables"
        CustomDimensions="Dimensions"
/>
}

You must set the ApiUrl and SiteId. The optional UserIdFunc, CustomVariables, and CustomDimensions let you set a user ID, custom variables, and custom dimensions. Store ApiUrl and SiteId in the appsettings.json if desired:

{
  "Matomo": {
    "ApiUrl": "https://your-matomo-url.com/",
    "SiteId": 1
  }
}

Custom Dimensions

Dimensions must be created in the Matomo dashboard before they can be used. The index of the custom dimension must be passed to the CustomDimensions property. The index is the number that appears in the Matomo dashboard when you create the custom dimension. The value of the custom dimension can be set using the CustomDimensions property. The Matomo component takes an array of CustomDimension objects. Each CustomDimension object takes the index of the custom dimension and the value to be set.

    private CustomDimension[] Dimensions { get; set; } =
    [
        new CustomDimension(1, "Value for Dimension 1")
    ];

Custom Variables

In order to use the custom variables the plugin must be enabled in the matomo settings. The Matomo component takes an array of CustomVariable objects. Each CustomVariable object takes the index of the custom variable, the name of the custom variable, and the value to be set as well as the scope of the variable. The scope can be set to Visit or Page. The value of the custom variable can be set using the CustomVariables property.

    private CustomVariable[] Variables { get; set; } =
    [
        new CustomVariable(1, "User Name", "John Smith", VariableScope.Visit)
    ];

User Id

The UserIdFunc property is a Func<string> that returns a string. This function is called when the component is initialized and the return value is set as the user id for the current user. The user id can be used to track a user across multiple sessions. The user id can be set to a unique identifier for the user.

    private Task<string> UserId()
    {
        var timestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
        var guid = Guid.NewGuid().ToString();
        return Task.FromResult($"{guid}-{timestamp}");
    }

Additional Notes

  • The compose.yml file provides a fast way to launch a local Matomo instance for development purposes.
  • This project has not been tested on the Blazor Hybrid App with interactivity set to per page/component.
  • While not tested, the hybrid app should work as long as the script and component is placed in the correct location depending on the interactivity setting and your project structure.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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

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
10.0.8 150 5/16/2026
10.0.3 925 2/18/2026
10.0.2 244 2/2/2026
10.0.0 446 11/19/2025
9.0.4 599 8/26/2025
9.0.2 305 6/24/2025
9.0.1 278 4/24/2025
1.0.0 255 3/5/2025