CodeArt.MatomoTracking 1.0.5

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

// Install CodeArt.MatomoTracking as a Cake Tool
#tool nuget:?package=CodeArt.MatomoTracking&version=1.0.5                

Nuget

CodeArt.MatomoTracking

Opensource Matomo Tracking API for .NET. This library is based on the official Matomo Tracking API documentation: https://developer.matomo.org/api-reference/tracking-api and wraps the API calls in a simple to use .NET library. Initial version made by Allan Thraen for CodeArt.

Installation

Register the Matomo Tracking as a service in Dependency Injection.

        var services = new ServiceCollection();
        
        //Needs IConfiguration - but this might already be registered in your project
        services.AddScoped<IConfiguration>(_ => configuration);
		
        services.AddMatomoTracking(options =>
        {
            options.MatomoUrl = "https://[My matomo hostname]/";
            options.SiteId = "[My site id]";
            options.AuthToken ="[My auth token]"; //Optional
            options.TrackBots = true; //Optional
            options.VerboseLogging = true; //Optional - logs the URLs tracked.
        });
        var serviceProvider = services.BuildServiceProvider();

Configuration

If you have a configuration file, you can also set the configuration directly there under the "Matomo" node.

{
  "Matomo": {
	"MatomoHostname": "[My matomo hostname]",
	"SiteId": "[My site id]"
  }
}

Usage

You can track many different things, for example:

  • Pageviews using PageViewTrackingItems
  • Events using EventTrackingItems
  • Ecommerce using EcommerceTrackingItems
  • Content using ContentTrackingItems

For the official documentation of what to track - and when, refer to the (official documentation)[https://developer.matomo.org/api-reference/tracking-api]

Tracking a page view


    await tracker.Track(new PageViewTrackingItem()
    {
        Url = "app://myapp/page1",
        UserID = "test@test.com",
        NewVisit = true,
        ActionName = "Page 1",
        PageViewID = pvid
    });

Tracking in bulk

You can also track multiple items in the same call like this:

    await tracker.Track(new PageViewTrackingItem()
    {
        Url = "app://myapp/page1",
        UserID = "test@test.com",
        NewVisit = true,
        ActionName = "Page 1",
        PageViewID = pvid
    },
    new EventTrackingItem()
    {
        Url = "app://myapp/page1",
        UserID = "test", 
        NewVisit = false,
        ActionName = "Form submit",
        PageViewID = pvid,
        EventCategory = "Form",
        EventAction = "Submit",
        EventName = "Newsletter form"
    });
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.0.5 10,451 5/3/2023
1.0.4 805 4/5/2023
1.0.3 322 2/20/2023
1.0.2 1,770 2/8/2023
1.0.1 397 1/28/2023
1.0.0 305 1/26/2023
1.0.0-preview3 185 1/26/2023
1.0.0-preview2 176 1/25/2023
1.0.0-preview1 158 1/25/2023