flutter_matomo 1.2.0

flutter_matomo #

Matomo tracking for flutter

Works on both Android and/or iOS. Version 1.1.4 supports AndroidX.

Dart package

Gitlab link

How to use #

Initialize Matomo/Piwik #

await FlutterMatomo.initializeTracker('https://YOUR_URL/piwik.php', SITE_ID);

Important: It does not matter if you are using piwik or matomo, you need to append piwik.php and not matomo.php

Adding a screen open event #

If you have the BuildContext this will automatically add the widget name

await FlutterMatomo.trackScreen(context, "Screen opened")

If not or you want to enter a custom name then use this

await FlutterMatomo.trackScreenWithName("SomeWidgetName", "Screen opened");

Extending out of the box TraceableWidgets #

You can also use TraceableStatefulWidget, TraceableStatelessWidget & TraceableInheritedWidget Where you get a screen open event with the name of the widget out of the box

Example #


class HomeWidget extends StatefulWidget {

with this

class HomeWidget extends TraceableStatefulWidget {

Or you can override the tracking name of the widget by overriding the name attribute

class HomeWidget extends TraceableStatefulWidget {
  HomeWidget({Key key}) : super(key: key, name: 'ONLY_IF_YOU_WANT_TO_OVERRIDE_THE_WIDGET_NAME');

  _HomeWidgetState createState() => _HomeWidgetState();

Tracking an event #

If you have the BuildContext this will automatically add the widget name

await FlutterMatomo.trackEvent(context, "Sign up button", "Clicked");

If not or you want to enter a custom name then use this

await FlutterMatomo.trackEventWithName("SomeWidgetName", "Sign up button", "Clicked");

Track app download (ONLY ON ANDROID) #

await FlutterMatomo.trackDownload();

Track goal with id (ONLY ON ANDROID) #

await FlutterMatomo.goal(GOAL_ID);

Full Example #

Future<void> initPlatformState() async {
    _matomoStatus = await FlutterMatomo.initializeTracker('https://YOUR_URL/piwik.php', SITE_ID);

    setState(() {});

    Future.delayed(Duration(seconds: 2), () async {
      _matomoStatus = await FlutterMatomo.trackScreen(context, "Screen opened");
      setState(() {});

    Future.delayed(Duration(seconds: 4), () async {
      _matomoStatus = await FlutterMatomo.trackScreenWithName("This uses a name MyAppWidget", "Screen opened");
      setState(() {});

    Future.delayed(Duration(seconds: 6), () async {
      _matomoStatus = await FlutterMatomo.trackEvent(context, "Sign up button", "Clicked");
      setState(() {});

    Future.delayed(Duration(seconds: 8), () async {
      _matomoStatus = await FlutterMatomo.trackEventWithName("LoginWidget", "Login button", "Clicked");
      setState(() {});

    Future.delayed(Duration(seconds: 10), () async {
      _matomoStatus = await FlutterMatomo.trackDownload();
      setState(() {});

    Future.delayed(Duration(seconds: 12), () async {
      _matomoStatus = await FlutterMatomo.trackGoal(1);
      setState(() {});

    if (!mounted) return;

1.2.0 #

  • Compatibility with gradle 5.x

1.1.9 #

  • Matomo flutter initial release


flutter_matomo_example #

Demonstrates how to use the flutter_matomo plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_matomo: ^1.2.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_matomo/flutter_matomo.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health suggestions

Fix lib/flutter_matomo.dart. (-0.50 points)

Analysis of lib/flutter_matomo.dart reported 1 hint:

line 121 col 9: The value of the local variable 'secondsSpent' isn't used.

Format lib/generated/i18n.dart.

Run flutter format to format lib/generated/i18n.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies