mautic_tracking_api 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • new54

mautic_tracking_api #

App User Monitoring and Tracking easily for Dart and Flutter using Mautic: Open Source Marketing Automation Software.

The essence of monitoring what happens in an App is similar to monitoring what happens on a website.

In short, this package use Named Screen Path (e.g. main_screen) in your App as your page_url field in the tracker, Named Screen Title (e.g. Home Screen) as your page_title field and the Contact E-mail as unique identifier. See Mautic Contact Monitoring section for detailed instructions.

This package also use native Mautic Tracking Cookies mtc_id, mtc_sid and mautic_device_id to make Tracking more effective.

Made with ❤️ by Mautic Specialists at Powertic.

Install #

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

dependencies:
  mautic_tracking_api:

Run flutter pub get on terminal to download and install packages and import on your main.dart:

import 'package:mautic_tracking_api/mautic_tracking_api.dart';

Usage #

Create a global instance of MauticTracking and import this global instance on all your files.

var MauticTracking mautic;

On your main.dart you can setting up the MauticTracking object:

// Setting Up
void main() async {

  // Start Tracking
  mautic = MauticTracking(
    "https://mkt.mymautic.com",
    appName: "MyApp",
    email: "contact@email.com",
    appVersion: '1.0.0',
    appBundleName: 'com.mydomain.myapp',
  );

  // Track App Start
  await mautic.trackAppStart();

}

When the App is Started, this event will be fired:

Started App

If the contact doesn't exists on Mautic, the contact will be identified by app_started.

Contact Identified

See a complete Flutter example at example/example_app/lib/main.dart

Setting Up #

There are some options to instantiate MauticTracking:

MauticTracking(
    this._base_url, {
    this.email,
    this.appName,
    this.appVersion,
    this.appBundleName,
    this.closeConnectionAfterRequest = true,
    this.userAgent =
        'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0)',
  });

These are the constructor options:

PropertyTypeRequiredDescription
_base_urlStringYesMautic Base URL
emailStringNoMautic Contact Email
appNameStringNoApp Name
appVersionStringNoApp Version
appBundleNameStringNoApp Bundle Name
closeConnectionAfterRequestboolNoClose Connection after Request
userAgentStringNoRequest User Agent

Mautic Contact Monitoring #

The act of monitoring the traffic and activity of contacts can sometimes be somewhat technical and frustrating to understand. Mautic Tracking API makes this monitoring simple and easy to configure.

Contact Timeline

Tracking Screens #

Send App Screen info to Mautic.

Screen Track

Method Definition:

Future<void> trackScreen(String screenPath, [String screenName]) async;
PropertyTypeRequiredDescription
screenPathStringYesUnique Screen Route Path
screenNameStringNoUnique Screen Route Label

Usage:

You can send screen tracking info only with screenPath.

Create your screen paths using _ to separate words and always use small caps.

mautic.trackScreen("main");

You can also send screen tracking info using screenPath and screenName. Fell free to use space and capitalized words for Screen Name.

mautic.trackScreen("main", "Main Page");

Tracking Events #

Send App Event info to Mautic.

Event Track

Method Definition:

Future<void> trackEvent(String eventKey, String eventName, String screenPath, [String screenName]) async;
PropertyTypeRequiredDescription
eventKeyStringYesUnique Event Key
eventNameStringYesUnique Event Name
screenPathStringYesUnique Screen Route Path
screenNameStringNoUnique Screen Route Label

Usage:

You can send screen tracking info only with screenPath.

Create your screen paths using _ to separate words and always use small caps.

mautic.trackEvent('click_getting_start', 'Click Get Start Button', 'home');

You can also send screen tracking info using screenPath and screenName. Fell free to use space and capitalized words for Scren Name and Event Name.

mautic.trackEvent('click_getting_start', 'Click Get Start Button', 'home', 'Home Page');

Adding Contact Tags #

Add tag to contact.

Contact Timeline

mautic.addTag({'a', 'b'});
PropertyTypeRequiredDescription
paramsSetYesSet of tag names

Removing Contact Tags #

Remove tag to contact.

Contact Timeline

mautic.removeTag({'a', 'b'});
PropertyTypeRequiredDescription
paramsSetYesSet of tag names

Contribute #

Please file feature requests and bugs at the issue tracker.

Changelog #

1.0.2 #

  • Updated Readme

1.0.1 #

  • Updated Readme
  • Fix User Agent
  • Flutter Example

1.0.0 #

  • Initial Version
  • Track App Screens
  • Track App Events
  • Send Cookies to Tracking
  • Track using E-mail
  • Add Tags
  • Remove Tags
  • Track App Version
  • Track App Name
  • Customize Tracking User Agent

example/example.dart

import 'package:mautic_tracking_api/mautic_tracking_api.dart';

void main() async {
  // Start Tracking
  var m = MauticTracking(
    "https://mkt.mymautic.com",
    appName: "MyApp",
    email: "contact@email.com",
    appVersion: '1.0.0',
    appBundleName: 'com.mydomain.myapp',
  );

  /// Track App Start
  await m.trackAppStart();

  /// Track App Screen
  m.trackScreen("main", "Main Page");

  /// Track App Event
  m.trackEvent('click', 'Click Get Start Button', 'home', 'Home Page');

  /// Add Contact Tag
  m.addTag({'a', 'b'});
}

Use this package as a library

1. Depend on it

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


dependencies:
  mautic_tracking_api: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:mautic_tracking_api/mautic_tracking_api.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
9
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]
54
Learn more about scoring.

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

  • Dart: 2.7.0
  • pana: 0.13.4

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
http ^0.12.0+4 0.12.0+4
path ^1.6.0 1.6.4
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
meta 1.1.8
pedantic 1.9.0
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6