Tracking events is how you record any actions your users perform, along with any properties that describe the action. Every trackEvent call records a single user action. We recommend that you make your event names human-readable so that everyone on your team can know what they mean instantly.
Every TrackEvent() call expects 2 parameters, event name, and Properties instance which represent additional event attributes about the event. Add all the additional information which you think would be useful for segmentation while creating campaigns. For eg: the following example shows an example of tracking an event with all the possible data types.
import 'package:moengage_flutter/moengage_flutter.dart'; import 'package:moengage_flutter/model/geo_location.dart'; import 'package:moengage_flutter/properties.dart'; var properties = MoEProperties(); properties.addAttribute("attrString", "String Value") .addAttribute("attrInt", 123) .addAttribute("attrBool", true) .addAttribute("attrDouble", 12.32) .addAttribute("attrLocation", new MoEGeoLocation( 12.1, 77.18) ) .addAttribute("attrArray", ["item1", "item2", "item3"]) .addISODateTime("attrDate", "2019-12-02T08:26:21.170Z"); final MoEngageFlutter _moengagePlugin = MoEngageFlutter(YOUR_APP_ID); _moengagePlugin.initialise(); _moengagePlugin.trackEvent('Flutter Event', properties);
MoEngage SDK has started tracking user sessions and application traffic sources. Refer to the Sessions in MoEngage Analytics and Source Analysis in MoEngage Analytics to learn more about how user session and application traffic source tracking works.
With user session tracking we have introduced the flexibility to selectively mark events as non-interactive.
What is a non-interactive event?
Events that do not affect the session calculation in anyways are called non-interactive events. Non-interactive events have the below properties
- Do not start a new session.
- Do not extend the session.
- Do not have information related to a user session.
How to mark an event as non-interactive?
To mark an event as a non-interactive call setNonInteractiveEvent() for Properties instance as shown below:
import 'package:moengage_flutter/moengage_flutter.dart'; import 'package:moengage_flutter/properties.dart'; var properties = MoEProperties(); properties.addString( "attrString", "String Value") .addInteger("attrInt", 123) .setNonInteractiveEvent(); final MoEngageFlutter _moengagePlugin = MoEngageFlutter(YOUR_APP_ID); _moengagePlugin.initialise(); _moengagePlugin.trackEvent('Non Interactive Event', properties);