React Native Matomo integration
Clone or download
Latest commit 32907c8 Jul 27, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
android fixed android usage Sep 19, 2017
ios fixed iOS usage Sep 19, 2017
.gitignore Initial commit with piwik Android binding. Feb 22, 2017
LICENSE Initial commit Feb 21, 2017 Update Jul 27, 2018
index.js added support for app opt out Sep 19, 2017
package.json Bump version Sep 19, 2017

Matomo SDK for React Native

This document describes how to get started using the Matomo Tracking SDK for React Native. Matomo is the leading open source web analytics platform that gives you valuable insights into your website's visitors, your marketing campaigns and much more, so you can optimize your strategy and experience of your visitors. This relies on the native Android SDK and on the native iOS SDK for Matomo and this README page is heavily inspired by it.

Getting started

Integrating Matomo into your React Native app

  1. Install Matomo
  2. Create a new website in the Matomo web interface. Copy the Website ID from "Settings > Websites".
  3. Include the library
  4. Initialize Tracker.
  5. Track screen views, goals and more.

Include the library


  1. Add node_modules/react-native-matomo/ios/BNFPiwik.xcodeproj to your xcode project, usually under the Libraries group
  2. Add libBNFPiwik.a (from Products under BNFPiwik.xcodeproj) to build target's Linked Frameworks and Libraries list
  3. Drag node_modules/react-native-matomo/ios/PiwikTracker/piwiktracker.xcdatamodeld into the folder containing AppDelegate.m
  4. Delete piwiktracker.xcdatamodeld(from Libraries under BNFPiwik.xcodeproj/PiwikTracker)


  • Open /android/settings.gradle
  • Below include ':app' add:
include ':react-native-matomo'
project(':react-native-matomo').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-matomo/android/')
  • Open android/app/build.gradle
  • Add the following under dependencies:
compile project(':react-native-matomo')
  • Open your file under android/src
  • Import the lib using import de.bonify.reactnativepiwik.PiwikPackage;
  • Add the following new PiwikPackage() to the getPackages function.

Tracker Usage

Init tracker

Before using any function below, the tracker must be initialized.

Piwik.initTracker('https://your-piwik-domain.tld/piwik.php', 1);

Set User ID

Providing the tracker with a user ID lets you connect data collected from multiple devices and multiple browsers for the same user. A user ID is typically a non empty string such as username, email address or UUID that uniquely identifies the user. The User ID must be the same for a given user across all her devices and browsers. . If user ID is used, it must be persisted locally by the app and set directly on the tracker each time the app is started.

If no user ID is used, the SDK will generate, manage and persist a random id for you.


Track screen views

To send a screen view set the screen path and titles on the tracker.

Piwik.trackScreen('/your_activity', 'Title');

Track events

To collect data about user's interaction with interactive components of your app, like button presses or the use of a particular item in a game use trackEvent.

Piwik.trackEvent('category', 'action', 'label', 1000);

Track goals

If you want to trigger a conversion manually or track some user interaction simply call the method trackGoal. Read more about what is a Goal in Piwik.

Piwik.trackGoal(1, revenue);

Track App Downloads

If you want to track the app downloads, there is also a function to do that (only supported on Android).


Setting App Opt Out

The PiwikTracker SDK supports opting out of tracking. Note that this flag must be set each time the app starts up and will default to false. To set the app-level opt out, use:



  • Fork the project
  • Create a feature branch based on the 'master' branch
  • Create a PR and feel proud.


react-native-piwik is released under the MIT license, see LICENSE.