Web SDK Events Tracking


MoEngage highly recommends using the optional step for MoEngage Web SDK integration.

Track Event

Tracking events records the user actions and the action properties. A single user action is recorded with every track_event call. MoEngage recommends that you make your event names human-readable so that everyone in your team can know what they mean instantly.

You can track an event using track_event with the event name and the event characteristics such as attributes or properties.

Moengage.track_event("EVENT_NAME_1"); // This event has no attributes
    // Track events with additional attributes
    Moengage.track_event("EVENT_NAME_2", {
    "attribute_1": "value_1", // string value
    "attribute_2": 2, // numeric value
    "attribute_3": 3.4, // numeric value
    "attribute_4": new Date(2017, 0, 31), // datetime value. Example value represents 31 January, 2017.

Add all the additional information which you think would be useful for segmentation while creating campaigns. For example, the following code tracks a purchase event of a product. We are including attributes like amount, quantity, category, which describe the event we are tracking.

Moengage.track_event("Purchase", {
 "product_name":"Ipad mini",
 "price": 599.99,
 "currency": "USD"


Ensure that you are tracking event and user attributes without changing their data types. For instance, in the above purchase event, amount and quantity are tracked in numeric form. MoEngage detects the data type automatically unless you explicitly specify it as a string.

Event tracking using Google Tag Manager (GTM)

Use the described code in the Custom HTML Tag inside GTM. This Tag should be fired once per event and triggered on the elements where you wish to track website events. The event attributes can be picked up from GTM Data Layer.

Moengage.track_event("Purchase", {"quantity":2, "product_name":"Ipad mini", "price": 599.99, "currency": "USD" });

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

For example, events that are tracked when the app is in the background to refresh the app content, are not initiated by users and hence are marked as non-interactive.

To mark an event as non-interactive send moe_non_interactive: 1 while tracking the event as described:

Moengage.track_event("App Content Refreshed", {"NewsCategory": "Politics", "moe_non_interactive": 1})

Reach out to us directly from your MoEngage Dashbaord -> Need Help? -> Contact Support or send an email to support@moengage.com.

Was this article helpful?
0 out of 0 found this helpful