- We track certain events by default in our SDK, so please make sure to use the default events instead of tracking a new event for the same scenarios. Find the list of default events tracked by SDK here.
- SDK adheres to the MoEngage FUP policies. For more information, refer to the Fair Usage Policy.
How to track events?
Every event has 2 parts to it, the “name” of the event and the properties/attributes of the event. You have to make use of MoEngageProperties to track events and their attributes. For eg. The following code tracks aSuccessful Purchase event. We are including attributes like the Product Name, a Brand Name that describes the event we are tracking.
Non-Interactive EventsEvents that should not affect the session duration calculation in anyways in MoEngage Analytics should be marked as a Non-Interactive events. Refer to this for more info on the same.
Validations and restrictions
Event attributes have two layers of validation that apply across bothDEBUG and release builds:
- Naming and format rules — these always apply, regardless of build configuration. Refer to Naming and format rules below.
- Type validation — invalid attribute values (unsupported types such as
null, custom models,NaN,Infinity, empty collections, orDate/MoEngageGeoLocationnested inside an Array or Dictionary) cause a fatal exception inDEBUGbuilds and are silently dropped from the payload in release builds. The rest of the event is tracked. Refer to Supported attribute value types below.
In the iOS SDK,
DEBUG mode means the SDK was initialized using initializeDefaultTestInstance(_:) (TEST workspace) and the app is running attached to Xcode. This is different from a release build that has debug symbols enabled.Naming and format rules
- Attribute names must be non-empty. Passing an empty string (
"") as an attribute name causes a fatal exception inDEBUGbuilds. In release builds, the attribute is dropped. - 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
Attribute values must be one of:String, Number, Date, MoEngageGeoLocation, Dictionary (with string keys and supported values), or Array (of supported values). If an unsupported value is passed:
- In
DEBUGbuilds, the SDK throws a fatal exception and crashes the app to surface data issues early in development. - In Release and TestFlight builds, the SDK silently drops the specific invalid attribute and logs the issue. The rest of the event payload is still tracked.
DEBUG exception:
- Passing
null(NSNull()). - Passing custom models or UI elements (for example,
UIColor,UIImage). - Passing invalid numbers like
NaNorInfinity. - Passing empty Arrays or Dictionaries.
- Nesting
DateorMoEngageGeoLocationobjects inside an Array or Dictionary. These must be passed directly as values.
If you are upgrading an existing app and these strict
DEBUG validations cause disruptive crashes while you refactor your tracking code, you can temporarily opt out by calling disableIntegrationValidator() during SDK initialization. Use this strictly as a stopgap for phased upgrades, and aim to remove the opt-out once your attribute call sites are properly validated.Filtering unsupported attribute values
If you are upgrading to a newer version of the iOS SDK and your app passes attribute values whose types are not validated at the call site, add a type-check guard before building theMoEngageProperties object. This prevents DEBUG crashes and ensures only valid data reaches the SDK in all builds.
Date and MoEngageGeoLocation values must be passed using the dedicated addDateAttribute, addDateEpochAttribute, addDateISOStringAttribute, and addLocationAttribute methods — not through the dictionary-based withAttributes: initializer or addAttribute:withName:.