GithubHelp home page GithubHelp logo

qinwenshi / flutter_matomo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mozes-pb/flutter_matomo

0.0 1.0 0.0 4.31 MB

License: MIT License

Kotlin 23.67% Ruby 16.93% Swift 14.29% Objective-C 2.08% Dart 43.02%

flutter_matomo's Introduction

flutter_matomo

NOTE: THIS IS A MIRROR OF https://gitlab.com/petleo-and-iatros-opensource/flutter_matomo ALL CREDITS GOES TO THE ORIGINAL DEVELOPER

Matomo tracking for flutter

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

Dart package

Gitlab link

About

Matomo/Piwik tracking for flutter, this library is based on the android and the ios libraries provided by the Matomo team. Matomo Android,

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

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;
  }

flutter_matomo's People

Contributors

karimabdo avatar qinwenshi avatar bulenthacioglu avatar petra-bios avatar mozes-pb avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.