Tracking Events

Tracking events is how you record any actions your users perform, along with any properties that describe the action.

JavaScript
var moe = MoECordova.init(YOUR_APP_ID);
moe.trackEvent(eventName, generalAttributes, locationAttributes, dateTimeAttributes, isNonInteractive);

The trackEvent() takes in 5 parameters eventName and eventAttribute.

  • eventName : String
  • generalAttributes : JSON Object for general attributes. Accepted data types are string, number, boolean
    JSON
    {
      "<attribute_name>": "<attribute_value>",
      "<attribute_name>": "<attribute_value>",
      "<attribute_name>": "<attribute_value>",
      ...  
    }
  • locationAttributes: JSON Object for location attributes. Accepts attribute name and latitude and longitude
    JSON
    {
      "<attribute_name>": {
        "latitude": <latitude>,
        "longitude": <longitude>
      },
      "<attribute_name>": {
        "latitude": <latitude>,
        "longitude": <longitude>
      },
      "<attribute_name>": {
        "latitude": <latitude>,
        "longitude": <longitude>
      },
      ...
    }
  • dateTimeAttributes: JSON Object for date-time attributes. Accepts only ISO-8601 format dates
    JSON
    {
      "<attribute_name>": "yyyy-MM-dd'T'HH:mm:ss.fff'Z'",
      "<attribute_name>": "yyyy-MM-dd'T'HH:mm:ss.fff'Z'",
      "<attribute_name>": "yyyy-MM-dd'T'HH:mm:ss.fff'Z'",
      ...
    }
  • isNonInteractive: true if you want the event to be non-interactive, else false.

Apart from the eventName parameter, other parameters are non-mandatory you can choose to pass null or {} or undefined.
It is important to maintain the order in which parameters are passed, i.e. if you want to pass only the location attributes general attribute should be passed null or {} or undefined

Example

JSON
   moe.trackEvent("testEvent", {"attr1": "string", "attr2": 123, "attr3": false},{"loc1": { "latitude": 14.90123,"longitude": 13.1627} },
    {"date1" : "2017-08-02T06:05:30.000Z"}, true);
info

Note

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.

Analytics

MoEngage SDK has started tracking user session and application traffic source. 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.

Previous

Next

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

How can we improve this article?