Giter Site home page Giter Site logo

kee-org / matomo-tracker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from floating-dartists/matomo-tracker

0.0 1.0 0.0 303 KB

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

Home Page: https://pub.dev/packages/matomo_tracker

License: MIT License

Ruby 4.05% Objective-C 0.11% Kotlin 0.37% Dart 89.75% Swift 1.21% HTML 4.50%

matomo-tracker's Introduction

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: '2589631479517535',
);

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

If you are in a StatelessWidget you can use the TraceableWidget widget:

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

  final String title;

  @override
  Widget build(BuildContext context) {
    return TraceableWidget(
      traceName: 'Created HomePage', // optional
      traceTitle: title,
      child: Scaffold(
        appBar: AppBar(
          title: Text(title),
        ),
        body: Center(
          child: Text('Hello World!'),
        ),
      ),
    );
  }
}

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: 18,
);

Using userId

If your application uses authentication and you wish to have your visitors including their specific identity to Matomo, you can use the Visitor property userId with any unique identifier from your back-end, by calling the setVisitorUserId() method. Here's an example on how to do it with Firebase:

  String userId = auth.currentUser?.email ?? auth.currentUser!.uid;
  MatomoTracker.instance.setVisitorUserId(userId);

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

Using Dimensions

If you want to track Visit or Action dimensions you can either use the trackDimensions (if it's a Visit level dimension) or provide data in the optional dimensions param of trackEvent (if it's an Action level dimension):

MatomoTracker.instance.trackDimensions({
  'dimension1': '0.0.1'
});
MatomoTracker.instance.trackEvent(
    name: 'eventName',
    action: 'eventAction',
    eventValue: 18,
    dimensions: {'dimension2':'guest-user'}
);

You can similarly track dimensions on Screen views with:

MatomoTracker.instance.trackScreenWithName(
      widgetName: "Settings",
      eventName: "screen_view",
      dimensions: {'dimension1': '0.0.1'}
    );

Contributors

TesteurManiak
Guillaume Roux
poitch
Jêrôme Poichet
M123-dev
Marvin Möltgen
krillefear
Krille Fear
scolnet
Scolnet
KawachenCofinpro
Null
stefan01
Null
MeixDev
Meï
petcupaula
Paula Petcu
lsaudon
Lsaudon
Bendix20
Null
lukaslihotzki
Lukas Lihotzki
svprdga
David Serrano Canales

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.