A fully cross-platform wrap of the Matomo tracking client for Flutter, using the Matomo API.

Overview

Matomo Tracker

Floating Dartists

Pub Version Matomo Integrations GitHub license

Forked from the package matomo by poitch.

A fully cross-platform wrap of the Matomo tracking client for Flutter, using the Matomo Tracking API.

Getting Started

As early as possible in your application, you need to configure the Matomo Tracker to pass the URL endpoint of your instance and your Site ID.

await MatomoTracker.instance.initialize(
    siteId: siteId,
    url: 'https://example.com/matomo.php',
);

If you need to use your own Visitor ID, you can pass it at the initialization of MatomoTracker as is:

await MatomoTracker.instance.initialize(
    siteId: siteId,
    url: 'https://example.com/matomo.php',
    visitorId: 'customer_1',
);

To track views simply add TraceableClientMixin on your State:

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with TraceableClientMixin {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Text('Hello World!'),
      ),
    );
  }

  @override
  String get traceName => 'Created HomePage'; // optional

  @override
  String get traceTitle => widget.title;
}

You can also optionally call directly trackScreen or trackScreenWithName to track a view.

For tracking goals and, events call trackGoal and trackEvent respectively.

A value can be passed for events:

MatomoTracker.instance.trackEvent(
    name: 'eventName',
    action: 'eventAction',
    eventValue: 'eventValue',
);

Opting Out

If you want to offer a way for the user to opt out of analytics, you can use the setOptOut() call.

MatomoTracker.instance.setOptOut(optout: true);
Comments
  • Problem with visitor id

    Problem with visitor id

    Hey,

    Problem on matomo_tracker 1.4.1 and above.

    If I call await MatomoTracker.instance.initialize( siteId: 123, url: 'someurl', );

    I always get image

    It works fine on 1.4.0.

    Maybe you could look into it.

    bug needs verification 
    opened by josefwilhelm-innio 13
  • firebase and visitorId

    firebase and visitorId

    First: thanks so much for creating/supporting this flutter package. That was one of the reasons I chose Matomo, because there is a current flutter SDK for it.

    Now, I'm using Firebase and I'm running into two problems:

    1. Firebase has a uuid which I'd like to put into visitorId, but Firebase's uuid has 26 characters (hex) whereas visitorId in matomo is required to be 16 characters. I guess I could just take the 16 last characters of Firebase and hope that they are unique. Or is there any better alternative?
    2. Upon the first launch of the app, a user has no Firebase user yet, only after the required registration. What's the best way to handle that? Can I call MatomoTracker.instance.initialize first without visitorId and then after registration I call it again? Or should I use MatomoTracker.instance.visitor = Visitor(id: _visitorId, userId: _visitorId)?
    documentation enhancement 
    opened by philippkeller 7
  • PII in the user agent string can cause tracking failure

    PII in the user agent string can cause tracking failure

    I noticed that on an iPhone, no events were being tracked because the User-Agent HTTP header is being set to an invalid value.

    This problem won't affect every device but is potentially not limited to iPhones.

    In the specific case, the iPhone running ios 12 set its device name to Firstname Lastname’s iPhone as a default configuration. It is therefore likely that many/most user's of iPhones have a device name in this format. I have no newer hardware available to verify if Apple have changed this behaviour in recent years but either way, the name may well persist across iOS upgrades to even the most up to date phones.

    Note that the apostrophe is not a standard ASCII apostrophe and thus it is not valid to be used in a HTTP header so Dart throws an error rather than submit the tracking request.

    I have fixed the issue through two different approaches.

    1. Stop setting the User-Agent HTTP Header to the device-specific value. Although I have only confirmed this works with existing users known to Matomo, I would expect that it works fine for new users too, since we already supply the ua parameter.
    2. Remove the iOS device name and equivalents for other operating systems from the User agent string.

    Either fix on its own would resolve this issue but I think the two combined are required to help protect against other unexpected device variables crashing the tracking process and to protect library users and end users from an unexpected leak of personal information.

    opened by luckyrat 5
  • Add pause and resume capabilities with lock mechanism to prevent concurrent access

    Add pause and resume capabilities with lock mechanism to prevent concurrent access

    Hello team,

    Thank you to develop this tracker for Matomo. 👍 I noticed that the timer keeps running when the app is in the background. So I added development to handle pause and resume timer if needed and I added a lock mechanism to prevent the queue from being processed concurrently if the processing is longer than the timer periodicity.

    Example of use

    void didChangeAppLifecycleState(AppLifecycleState state) {
        if (state == AppLifecycleState.paused) {
          MatomoTracker.instance.pause(); 
        } else if (state == AppLifecycleState.resumed){
          MatomoTracker.instance.resume();
        }
      }
    

    I let you see if this development is interesting for the project.

    Sébastien

    enhancement 
    opened by scolnet 4
  • Track duration in app

    Track duration in app

    Hello, thanks for building this great plugin. I wanted to ask if it is possible to track how long the user spent in the app or on a particular screen? Are there plans to implement this?

    Thanks again.

    documentation 
    opened by harrowmykel 4
  • Add support for Matomo Bulk Tracking REST API

    Add support for Matomo Bulk Tracking REST API

    These changes add a sendBatch(List<MatomoEvent>) function to the MatomoDispatcher, which sends the entire queue using only one HTTP POST request, as specified in the Matomo API documentation.

    Additionally I have fixed the error mentioned in #33, by saving the currentScreenId in the MatomoEvent itself. Previously only the latests screen id was used in all batched requests, which resulted in Matomo assuming that all batched tracking events were performed on the same screen.

    opened by JohannSchramm 3
  • fix: Event sending

    fix: Event sending

    Fixes: #9

    I found the problem for #9. when sending event's the event category is a mandatory field. Updated the code to reflect this. These are breaking changes

    bug 
    opened by M123-dev 3
  • Events not shown in the Backend

    Events not shown in the Backend

    I have running the Matomo Backend via Docker https://github.com/matomo-org/docker the nginx example, Matomo Version 4.9.1

    example call: http://localhost:8080/matomo.php?idsite=1&rec=1&url=https%3A%2F%2Fcom.example.example&_id=cf0cd7af39194e79&rand=822786072&apiv=1&_idvc=12&_viewts=1653736918&_idts=1653721097&res=1440x3064&h=11&m=22&s=1&cookie=1&ua=Android+12+%28SDK+32%29%2C+Google+Pixel+6+Pro&lang=de_DE&uid=cf0cd7af39194e79&pv_id=zhO56F&e_a=Click&e_n=IncrementCounter

    The API Call are received in the Backend but I cant see the Increment Counter event

    bug 
    opened by tilonet 3
  • The request does not come to matomo

    The request does not come to matomo

    Hello! We make a request to matomo using this SDK. The data has been sent successfully, but they do not come to matomo. Can you tell what we could have done wrong and what data you need to send to check it?

    We using matomo version 4.10.1 and sdk version 1.7.0

    bug needs verification 
    opened by AlexMarg21 2
  • queue in matomo.dart breaks tracking

    queue in matomo.dart breaks tracking

    Describe the bug Events that get sent in the same _dequeue() loop get picked up by our Matomo instance incorrectly. This means that for example 3 quick consecutive screen views get tracked as the first view x 3 by Matomo.

    To Reproduce Steps to reproduce the behavior:

    1. Send multiple events in rapid succession
    2. Verify in Matomo console

    Additional context For now, we have resorted to a slightly hacky workaround of calling dispatchEvents() after each tracking call. We have tried to remove the Queue from matomo.dart altogether and it seems to work. Maybe someone could give us some context on why the Queue was implemented in the first place, because we would have a PR ready with the Queue removed that worked great in our testing.

    bug 
    opened by timcreatedit 1
  • Feature: Add dimensions tracking

    Feature: Add dimensions tracking

    What

    • Adds support for tracking dimensions (Matomo documentation on Custom Dimensions: https://matomo.org/faq/reporting-tools/create-track-and-manage-custom-dimensions/)
    • As mentioned in https://github.com/Floating-Dartists/matomo-tracker/issues/16, example use cases would be tracking of App Version or tracking of App Content Language.

    Implementation considerations

    • Basically the dimensions are key value pairs, so in the proposed implementation just adding them to the query params.
    • There are two ways to add the dimensions, either when an event is tracked (and dimensions is an optional argument) via the updated trackEvent, or via a new function trackDimensions

    Documentation

    • Info on setting up custom dimensions on Matomo can be found here: https://matomo.org/faq/reporting-tools/create-track-and-manage-custom-dimensions/ and on the dimensions arguments in the API here: https://developer.matomo.org/api-reference/tracking-api
    • Updated also the README file with usage examples
    enhancement 
    opened by petcupaula 1
Releases(2.0.0)
Owner
Floating Dartists
A bunch of weebs doing Dart & Flutter code
Floating Dartists
A tracking app for tracking corona virus incidence around the world

?? COVID-19 Tracker A simple Flutter app to track COVID-19 cases. The data we provide is collected from World Health Organization (WHO), the US Center

Chiziaruhoma Ogbonda 2 Jul 21, 2020
A tracking app for tracking covid-19 cases around the world

?? COVID-19 Tracker A simple Flutter app to track COVID-19 cases. The data we provide is collected from World Health Organization (WHO), the US Center

Temitope Ajiboye 166 Nov 23, 2022
Cross-platform GitHub client in Flutter and BLoC clean architecture

FlutterHub Cross-platform GitHub client in Flutter and BLoC clean architecture. SwiftHub - Swift version is available Try Web version Get Started To g

Khoren Markosyan 36 Nov 12, 2022
A beautiful and cross platform NHentai Client, Support desktop and mobile phone

A beautiful and cross platform NHentai Client. Support desktop and mobile phone (Mac/Windows/Linux/Android/IOS).

null 324 Dec 29, 2022
Cross-platform frontend to Homebrew formulae API

Brewery A cross-platform frontend to Homebrew formulae API. Features Works on many platforms Supports formulae and casks Supports analytics Regexp fil

Dawid Dziurla 18 Nov 4, 2022
Flutter Android application for tracking Osu! user, beatmaps statistic and other features provided by Osu! API

TMP-team-2-Osu-track Целью проекта является написание приложения на платформе Android и IOS с помощью Dart+Flutter с интуитивно понятным интерфейсом,

Aleksandr P. 11 Nov 23, 2022
Cross platform application for iOS and Android using Google's SDK Flutter.

scout Cross platform application for iOS and Android using Google's SDK Flutter. Launch screen for the application. The menu for selecting cookies. Cu

null 0 Nov 9, 2021
A cross platform todo list app using flutter and dart programming language

Flutter Todos A cross platform todo list app using flutter and dart programming language. In this application, I used SQLite3 to persist data. The app

Mahmud Ahsan 61 Dec 29, 2022
Relive is a cross-platform application that can be used both in Android/IOS and it is made using Flutter

?? Introduction Relive is a cross-platform application that can be used both in Android/IOS and it is made using Flutter. It aims to solve the mental

Akshat Tripathi 14 Nov 4, 2022
Money Tracking App using Flutter

Money Tracking App using Flutter

Daniel Choi 46 Oct 11, 2022
Corona Shield is an open sourced Corona Tracking Mobile Application with Back-end made by Amine Jafur with ♥ using Flutter, PHP, JS.

Corona-Shield A Corona Tracking Mobile Application. Corona Shield is an open sourced Corona Tracking Mobile Application with Back-end made by Amine Ja

Amine Jafur 56 Dec 11, 2022
A simple, cross-platform password manager created with Flutter.

PassMan PassMan Logo © 2021 by Yash Ahir is licensed under CC BY-NC 4.0 A simple, cross-platform password manager created with Flutter. How to run thi

Yash Ahir 19 Dec 14, 2022
This is the new version of my Task app "Tasko" which was done in Java. She is now in Flutter for the HotReload and the native Cross-Platform.

tasko_rem The Tasko App is now compatible on iOS, Android and others distribution, because it's made with Flutter ✨ You can now add task, check them o

Scythe 12 May 2, 2022
A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter

quick_usb A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter Usage List devices List devices with additional description Get device

Woodemi Co., Ltd 39 Oct 1, 2022
The Fuse Wallet is a cross platform Ethereum wallet written in Dart and built on Flutter.

Fuse Wallet The Fuse Wallet is a cross platform Ethereum wallet written in Dart and built on Flutter. It's runninng on the Fuse network, but can be pl

null 4 Nov 9, 2022
Super Fast Cross Platform Database for Flutter & Web Apps

Isar Database ?? Alpha version - Use with care. ?? Quickstart • Documentation • Sample Apps • Support & Ideas • Pub.dev Isar [ee-zahr]: River in Bavar

Isar Database 2.1k Jan 1, 2023
A cross platform application written in flutter to help people stick to their routines and achieve their goals

Scheduler Scheduler is a cross platform application written in flutter to help people stick to their routines and achieve their goals. Our service inc

Sidheshwar S 3 Jan 21, 2022
A Cross Platform Piano made with Flutter

flutter_piano A Crossplatform Midi Piano built with Flutter.dev This application runs on both iOS and Android. This runs a custom crossplatform midi s

Rody Davis 380 Dec 14, 2022
Quiz App is cross-platform mobile app, that allows you to test your knowledge on various technologies through quizzes. It's built with Flutter & Dart

Quiz App is cross-platform mobile app, that allows you to test your knowledge on various technologies through quizzes. It's built with Flutter & Dart

Régis 6 Sep 19, 2022