MatomoProvider 0.1.1

dotnet add package MatomoProvider --version 0.1.1
NuGet\Install-Package MatomoProvider -Version 0.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="MatomoProvider" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MatomoProvider --version 0.1.1
#r "nuget: MatomoProvider, 0.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.
// Install MatomoProvider as a Cake Addin
#addin nuget:?package=MatomoProvider&version=0.1.1

// Install MatomoProvider as a Cake Tool
#tool nuget:?package=MatomoProvider&version=0.1.1

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

This component is based on cmoissl's Blazor.Matomo component but adapted to provide extra functionality, with a focus on Blazor WASM's SPA nature.

Some of the recommendations from Matomo's SPA tracking documentation have been applied to allow proper page, page title, referrer URL, and user id tracking. Other features may follow.

Registering the component

The recommended way to use MatomoProvider is to add it to the bottom of your App.razor file:

 <Router AppAssembly="@typeof(App).Assembly">
     ...
 </Router>

+@* Register matomo provider application-wide *@
+<MatomoProvider ApiUrl="@_matomoOptions.ApiUrl"
+                SiteId="@_matomoOptions.SiteId"
+                UserIdFunc="async () => await Task.FromResult(Guid.NewGuid().ToString())" />

 @code {

     [Inject]
     private MatomoOptions _matomoOptions { get; set; } = default!;

 }

You must provide:

  • ApiUrl: the endpoint at which your Matomo instance is hosted
  • SiteId: your Matomo website id

You may provide:

  • UserIdFunc: a function returning the user id to set for the current user

Adding the script reference

MatomoProvider comes bundled with a Javascript file which needs to be added as a script reference in wwwroot/index.html for Blazor WASM and Pages/_Host.cshtml for Blazor Server:

<body>
    ...

    <script src="_framework/blazor.server.js"></script>
+   <script src="_content/MatomoProvider/matomo-provider.js"></script>
</body>
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
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
0.1.1 1,753 5/29/2023
0.1.0 109 5/28/2023
0.1.0-alpha.2 65 5/28/2023