Skip to content

This library provides Matomo Tracking for Xamarin.Forms Apps

License

Notifications You must be signed in to change notification settings

bnotech/Matomo.Xamarin.Forms

Repository files navigation

Matomo.Xamarin.Forms

This library provides Matomo Tracking for Xamarin.Forms Apps.

Status

Continuous Integration

Initial Setup

Getting started with Matomo.Xamarin.Forms is pretty easy:

  1. Add the Matomo.Xamarin.Forms Nuget to your project

  2. In your App.xaml.cs add:

private static object _matomoSyncRoot = new object();
private static MatomoAnalytics _matomoAnalytics;
public static MatomoAnalytics MatomoAnalytics
{
    get
    {
        lock (_matomoSyncRoot)
            if (_matomoAnalytics == null)
            {
                _matomoAnalytics = new MatomoAnalytics("https://url.to.matomo.instance/", 1);
                _matomoAnalytics.AppUrl = "https://app/";
            }
        return _matomoAnalytics;
     }
}

The code above connects your app to site number 1 on your Matomo instance, change the Url and the Site ID accordingly. In addition this code will Expose the MatomoAnalytics class to your App by just calling App.MatomoAnalytics.

  1. In your App.xaml.cs OnSleep Method add:
MatomoAnalytics.LeavingTheApp();

The library will batch submit the tracking data upon the app going into Background, without this call you will not receive any Tracking Data!

  1. When using Shell navigation tracking page visits is made simple with the ShellHelper: Add to your OnAppearing methods the following call:
App.MatomoAnalytics.TrackPage(Shell.Current.Title, ShellHelper.Instance.CurrentPath);

ShellHelper.Instance.CurrentPath generates you the full path to the Page you are currently starting to watch.

Documentation

You can find a reference documentation here.

And a sample project in the Sample/ folder.

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.

About

This library provides Matomo Tracking for Xamarin.Forms Apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages