Functions

Prev Next

Methods

Initialize

Initializes the SDK. For a complete configuration of the Flutter Intelligence SDK, please check Configuration.

initialize(List<int> trackIds, String trackDomain) → Future<String?>

Optional setup functions

/**
 * We should use this function to enable batch support 
 * @size is one batch size (The recommended value is between 500 and 5000)
 */
setBatchSupportEnabledWithSize(bool isEnabled, int size) → Future<String?>
/**
 * log level
 */
setLogLevel(LogLevel logLevel) → Future<String?>
/**
 * Request Interval: define how often the library sends a request to the server. The minimum is 15 minutes, which is the default
 */
setRequestInterval(int intervalSize) → Future<String?>
/**
 * Only iOS function: The number of requests in the queue before write the database
 */
setRequestPerQueue(int requestNumber) → Future<String?>

JAVA

Build

Builds the SDK. For a complete configuration of the Flutter Intelligence SDK, please check Configuration. For Android, please refer to the section Initializing the SDK for Android.

build() → Future<void>

Track

This function sends data to the Mapp tracking server. To see the complete data configuration of the Mapp Intelligence Java library, please check Data. It's possible to send actionEvents and pageViewEvents.

The following data can only be sent via pageViewEvents:

  • Page

The following data can be sent only via actionEvents:

  • Action

The following information can be sent via both pageViewEvents and actionEvents:

  • Campaign

  • Customer

  • Product

  • Order

  • Goal

  • Session

The following information can be sent in MediaEvents:

  • Media

  • Action

  • E-commerce

  • Session

/**
 * @Action(Event) tracking function
 * @return void
 */
trackAction(ActionEvent actionEvent) → Future<void>
/**
 * @Media tracking function
 * @return void
 */
trackMedia(MediaEvent mediaEvent) → Future<void>
/**
 * @Page(Screen) trakcing function
 * @return void
 */
trackPage(String customName, [Map<String, String>? trackingParameters]) → Future<void>
/**
 * @ * @Page(Screen) trakcing function with custom data and PageViewEvent
 * @return void
 */
trackPageWithCustomData(PageViewEvent? pageViewEvent, [String? customName]) → Future<void>

Deep link

Deep Link tracking allows you to analyze campaigns that are deep-linked to a screen of your mobile app.

/**

 * @param url specifies the URL to be tracked. Please note that you need to use the campaign format used by Mapp Intelligence.

 * @return void

 */

trackUrl(String urlString, String? mediaCode) → Future<void>

/**

 * Campaign that uses "wt_mc" as media code.

*/

buttons.add(ElevatedButton(

      onPressed: () async {

        var urlString =

            "https://testurl.com/?wt_mc=email.newsletter.nov2020.thursday&wt_cc45=parameter45";

        PluginMappintelligence.trackUrl(urlString, null);

        String className = this.runtimeType.toString();

        PluginMappintelligence.trackPageWithCustomData(null, className);

      },

      child: Text('Test Link1'),

      style:

          ElevatedButton.styleFrom(primary: Theme.of(context).primaryColorDark),

    ));

/**

 * Campaign that uses a custom media code.

*/

    buttons.add(ElevatedButton(

      onPressed: () async {

        var urlString =

            "https://testurl.com/?customMc=email.newsletter.nov2020.thursday&wt_cc12=parameter12";

        PluginMappintelligence.trackUrl(urlString, "customMc");

        String className = this.runtimeType.toString();

        PluginMappintelligence.trackPageWithCustomData(null, className);

      },

Anonymous Tracking

With anonymous tracking, it’s possible to track usage of the mobile application without persistently tracking a user across sessions. When anonymous tracking is enabled, the default user identifier is not set. To provide better data quality during session tracking, a temporary session ID can be set. The temporary session ID identifies requests from the same session.

/**

 * Anonymous tracking can be called on initialization or during runtime.

*/

// Enable anonymous tracking. If needed, include a String of additional parameters to be excluded from tracking if anonymous tracking is enabled.  
setAnonymousTracking(bool enabled, List <String>) -> Future<void>

// Set a temporary session ID.

setTemporarySessionId(<String>) -> Future<String>

User Matching

User Matching allows you to use Intelligence analytics data to better target users via mobile push or in-app messages in Engage.

/**

 * User matching only works if anonymous tracking is inactive. It is possible to set user matching on initialisation as well as on runtime.

*/

setUserMatchingEnabled(bool enabled) → Future<void>

Opt-out

/**
 * set to true if you want to send the currently cached data before setting the opt-out. Default is false.
 */
optOutAndSendCurrentData(bool value) → Future<void>

Opt-in

/**
 * @return void
 */
optIn() → Future<void>

Get EverID

/**
 * @return everID
 */
getEverID() → Future<String>

Change TrackID and Track Domain on Runtime

It is possible to change the track ID and track domain on runtime.

/**
 * @return everID
 */
PluginMappintelligence.setIdsAndDomain([array String account ID], String track domain);

WebView

Follow these steps to enable Mapp Intelligence tracking inside WebView.

  1. Add a WebView to your app by adding webview_flutter to your pubspec.yaml and importing it:

    import 'package:webview_flutter/webview_flutter.dart';
  2. Create and configure your controller in initState() to initialize the WebView controller.

    final _controller = WebViewController()   ..setJavaScriptMode(JavaScriptMode.unrestricted);
  3. Initialize WebTrackingController by passing your WebView controller to WebTrackingController to enable tracking:

    WebTrackingController(controller: _controller);
  4. Load your tracked web page:

     _controller.loadRequest(   Uri.parse('https://demoshop.webtrekk.com/media/web2app/index.html'), );
  5. To display the WebView, use the WebViewWidget, and pass in your controller:

    WebViewWidget(controller: _controller);

Full Example

class WebviewScreen extends StatefulWidget {

  @override

  WebviewScreenState createState() => WebviewScreenState();

}

class _WebviewScreenState extends State<WebviewScreen> {

  late final WebViewController _controller;

  @override

  void initState() {

    super.initState();

    _controller = WebViewController()

      ..setJavaScriptMode(JavaScriptMode.unrestricted);

    WebTrackingController(controller: _controller);

    _controller.loadRequest(

      Uri.parse('https://demoshop.webtrekk.com/media/web2app/index.html'),

    );

  }

  @override

  Widget build(BuildContext context) {

    return WebViewWidget(controller: _controller);

  }

}

Send Request Immediately (Android only)

Due to the use of WorkManager, Android is limited in terms of the scheduled sending of requests. As long as the app is used in the foreground, it is possible to trigger the sending of requests on any event trigger.

PluginMappintelligence.sendAndCleanData()

Print Current Configuration

While testing and debugging the configuration, it can be helpful to print out the currently active global configuration to the console.

PluginMappintelligence.getCurrentConfig()

Reset Singleton

It's helpful to be able to reset the Intelligence singleton for testing purposes. Resetting the singleton will reset the SDK configuration to its default values.

PluginMappintelligence.reset()