flutter_matomo 1.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 82

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 #

Replace

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');

  @override
  _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

example/README.md

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:


dependencies:
  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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
64
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
82
Learn more about scoring.

We analyzed this package on Dec 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

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.

Dependencies

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.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test