Matomo.Maui 8.0.0-pre005

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

// Install Matomo.Maui as a Cake Tool
#tool nuget:?package=Matomo.Maui&version=8.0.0-pre005&prerelease                

Matomo.Maui

This library provides Matomo Tracking for .NET MAUI Apps.

Status

Continuous Integration NuGet

Releases

This library is published for .NET 8.0 and above.

Documentation

You can find a reference documentation here.

And a sample project in the Sample/ folder.

Getting started

First add the following section to your appsettings.json:

{
  // ...
  "Matomo": {
    "ApiUrl": "https://matomo.org",
    "SiteId": 1,
    "SiteUrl": "https://app"
  }
  // ...
}

ApiUrl is the Url of your Matomo instance

SiteId is the ID of the Matomo Website you registered for the App

SiteUrl is the Url you registered for the App in the Matomo Website

Now add the Matomo.Maui Nuget Package to your project:

dotnet add package Matomo.Maui

Or use your IDE for the job. Next we need to setup Matomo in the MauiProgram.cs:

// ...

var builder = MauiApp.CreateBuilder();

builder
    .UseMauiApp<App>()
    .ConfigureFonts(fonts =>
    {
        fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
        fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
    })
    .UseMatomo(); // <-- Add this line

// ...

return builder.Build();

Last but not least setup your app for dispatiching the events to your Matomo Instance in App.xaml.cs:

using Matomo.Maui.Models;

namespace Matomo.Maui.Sample;

public partial class App : Application
{
	private IMatomoAnalytics _matomo;
	
	public App(IMatomoAnalytics matomo)
	{
		_matomo = matomo;
		_matomo.Verbose = true; // recommended for debug use only
		_matomo.OptOut = false; // if you are not hosting your own Matomo instance, please use this in order to provide your user a option to opt-out of tracking.
		_matomo.Dimensions.Add(new Dimension(id: 1, name: "AppVersion", currentValue: AppInfo.VersionString)); // remember to add your custom Dimensions in your Matomo instance first.
		
		InitializeComponent();

		MainPage = new AppShell();
	}

	protected override async void OnSleep()
	{
		base.OnSleep();

		try
		{
			await _matomo.LeavingTheApp(); // <-- Having this call awaited is important for the dispatch to complete.
		}
		catch (Exception ex)
		{
			System.Diagnostics.Debug.WriteLine(ex.Message);
		}
	}
}

You now have access to Matomo via dependency injection, just reference IMatomoAnalytics in order to have the service injected.

There is also IShellHelper that helps you to get the current path of the current page. However this is optional.

Credit

This work is based on the work done at zauberzeug/xamarin.piwik

License

This project retains the MIT license as per the original project.

Support

In case of issues with the library feel free to provide feedback via the Issues tab or if you want to support the project feel free to contribute via Pull Request.

If you need assistance getting started with Matomo and .NET MAUI feel free to reach out.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-ios18.0 is compatible.  net8.0-maccatalyst was computed.  net8.0-maccatalyst18.0 is compatible.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0 was computed.  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. 
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
8.0.0-pre005 32 1/14/2025
8.0.0-pre004 32 1/14/2025
7.1.1 313 2/23/2023
7.1.1-pre001 154 2/23/2023
6.1.1 257 2/23/2023
6.1.0-pre017 160 2/23/2023