MatomoProvider 0.1.0-alpha.2

This is a prerelease version of MatomoProvider.
There is a newer version of this package available.
See the version list below for details.
dotnet add package MatomoProvider --version 0.1.0-alpha.2                
NuGet\Install-Package MatomoProvider -Version 0.1.0-alpha.2                
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.0-alpha.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MatomoProvider --version 0.1.0-alpha.2                
#r "nuget: MatomoProvider, 0.1.0-alpha.2"                
#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.0-alpha.2&prerelease

// Install MatomoProvider as a Cake Tool
#tool nuget:?package=MatomoProvider&version=0.1.0-alpha.2&prerelease                

MatomoProvider

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 has been applied to allow proper page, page title, referrer URL, and user id tracking. Other features may follow.

Usage

TODO: add nuget

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>

Development

For ease of development, a docker image has been provided (/tools/matomo) that sets up a mariadb and a matomo instance.

After starting up this docker image, follow the setup instructions (at http://localhost), this should be limited to pressing "next" until asked to create an admin account.

Once the setup is complete no extra configuration needs to be made, the samples should work as-is.

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 2,619 5/29/2023
0.1.0 141 5/28/2023
0.1.0-alpha.2 77 5/28/2023