Skip to main content

Documentation Index

Fetch the complete documentation index at: https://moengage-crashes-in-debug-feedback.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

SDK adheres to the MoEngage FUP policies. For more information, refer to the Fair Usage Policy.
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. You can track an event using trackEvent with the event name and its characteristics (attributes/properties). Every event has 2 attributes, action name, and key, value pairs which represent additional information about the action. Add all the additional information which you think would be useful for segmentation while creating campaigns. For eg., the following code tracks a purchase event of a product. We are including attributes like amount, quantity, a category that describes the event we are tracking. For eg. The following code tracks an Purchase event. We are including attributes such as the quantity, product name that describes the event we are tracking.
val properties = Properties()
    properties
        // tracking integer
        .addAttribute("quantity", 2)
        // tracking string
        .addAttribute("product", "iPhone")
        // tracking date
        .addAttribute("purchaseDate", Date())
        // tracking double
        .addAttribute("price", 5999.99)
        // tracking location
        .addAttribute("userLocation", GeoLocation(40.77, 73.98))
        // tracking JSONArray 
        .addAttribute("jsonArrayAttr", JSONArray(listOf(1, 2, 3)))
        // tracking JSONObject
        .addAttribute("jsonObjectAttr", JSONObject().put("name", "value"))
MoEAnalyticsHelper.trackEvent(context, "Purchase", properties)
context - context instance, change the name accordingly.

Analytics

MoEngage SDK version 9.7.01 and later tracks user session and application traffic source. User session tracking provides the flexibility to selectively mark events as non-interactive.

Non-interactive event

Events that do not affect the session duration calculation in MoEngage Analytics are marked as Non-Interactive events. The following are considered non-interactive events:
  • Do not start a new session, even when the app is in the foreground
  • Do not extend the session
  • Do not have information on source and session
An event is marked as non-interactive using the setNonInteractive() in the PayloadBuilder provided by the SDK to build event attributes. For example,
val properties = Properties()
properties.addAttribute("quantity", 2)
    .addAttribute("product", "iPhone")
    .addAttribute("purchaseDate", Date())
    .addAttribute("price", 5999.99)
    .addAttribute("currency", "dollar")
    .addAttribute("jsonObjectAttr", JSONObject().put("name", "value"))
    .addAttribute("jsonArrayAttr", JSONArray(listOf(1, 2, 3)))
    .setNonInteractive()
MoEAnalyticsHelper.trackEvent(context, "Purchase", properties)
For more information, refer to MoEAnalyticsHelper#trackEvent and Properties.

Validations and restrictions

Event attributes have two layers of validation that apply across both debug and release builds:
  • Naming and format rules — these always apply, regardless of build configuration.
  • Type validation — invalid attribute values cause a fatal exception in debug builds and are silently dropped from the payload in release builds. The rest of the event is tracked.

Naming and format rules

  • Reserved prefixes. You cannot use moe_ as a prefix when naming events, event attributes, or user attributes. It is a system prefix, and using it might result in periodic blocklisting without prior communication.

Supported attribute value types

MoEngage supports the following data types: String, Integer, Long, Double, Float, Boolean, Date, GeoLocation, JSONObject, and JSONArray. If an unsupported value is passed:
  • Starting from SDK version 13.6.00, in debug builds the SDK throws an exception and crashes the app to surface data issues early in development.
  • In release builds, the SDK silently drops the specific invalid attribute and logs the issue. The rest of the event payload is still tracked.

Track Custom Event for Exit Intent

MoEngage SDK optionally notifies the application whenever the goes to the background. The application can track the custom event in this callback for exit intent. To get notified implement the AppBackgroundListener. Register the listener in the onCreate() of your Application class using MoECallbacks.getInstance().addAppBackgroundListener().
You can not use “moe_” as a prefix while naming events, event attributes, or user attributes. It is a system prefix and using it might result in periodic blacklisting without prior communication.