Maropost for Marketing provides a standard set of Events for capturing the most common types of activities within a mobile app. They include the following:
- added_to_cart — Use this event to track when a user adds an item to the mobile cart.
- removed_from_cart — Use this event to track when a user removes an item from the mobile cart.
- started_checkout — Use this event to track when a user starts the mobile cart checkout process.
- completed_checkout — Use this event to track when a user completes the mobile cart checkout process.
- started_content — Use this event to track when a user has started viewing in-app content such as an article or a video.
- finished_content — Use this event to track when a user has finished viewing in-app content.
To implement standard event tracking in the application, add the following functions:
Android
added_to_cart
MPPush.shared().addedToCart(jsonObject, this)
where, jsonObject is the JSON payload with key value fields and ‘this’ in the argument is used to initialize the callback to obtain the result of the API.
Example:
jsonObject?.put("event_name","added_to_cart")
jsonObject?.put("cart_id","123456")
jsonObject?.put("sku","MG-247")
jsonObject?.put("description","Magnalite Heavy Duty Flashlight")
jsonObject?.put("quantity", 1)
jsonObject?.put("value",19.95)
jsonObject?.put("product_category","Flashlight")
jsonObject?.put("brand","Magnalite")
Similarly, create JSON payloads for other standard events as well. See Event Attributes below to see the list of attributes expected for all standard events.
removed_from_cart
MPPush.shared().removedFromCart(jsonObject, this)
started_checkout
MPPush.shared().startedCheckout(jsonObject, this)
completed_checkout
MPPush.shared().completedCheckout(jsonObject, this)
started_content
MPPush.shared().startedContent(jsonObject, this)
finished_content
MPPush.shared().finishedContent(jsonObject, this)
iOS
added_to_cart
Swift
MPPush.shared.addedToCart(withProperties: postDict) { (response, status) in }
Objective C
[[MPPush shared] addedToCartWithProperties:postDict completionHandler:^(NSDictionary *response, BOOL status) {
}];
Where postDict is the dictionary containing the event parameters (event fields) and their values.
Example
postDict["event_name"] = "added_to_cart"
postDict["cart_id] ="123456"
postDict["sku"] = "MG-247"
postDict["description"] = "Magnalite Heavy Duty Flashlight"
postDict["quantity"] = 1
postDict["value"] = 19.95
postDict["product_category"] = "Flashlight"
postDict["brand"] = "Magnalite"
removed_from_cart
Swift
MPPush.shared.removedFromCart(withProperties: postDict) { (response, status) in }
Objective C
[[MPPush shared] removedFromCartWithProperties:postDict completionHandler:^(NSDictionary *response, BOOL status) {
}];
started_checkout
Swift
MPPush.shared.startedCheckout(withProperties: postDict) { (response, status) in }
Objective C
[[MPPush shared] startedCheckoutWithProperties:postDict completionHandler:^(NSDictionary *response, BOOL status) {
}];
completed_checkout
Swift
MPPush.shared.completedCheckout(withProperties: postDict) { (response, status) in }
Objective C
[[MPPush shared] completedCheckoutWithProperties:postDict completionHandler:^(NSDictionary *response, BOOL status) {
}];
started_content
Swift
MPPush.shared.startedContent(withProperties: postDict) { (response, status) in }
Objective C
[[MPPush shared] startedContentWithProperties:postDict completionHandler:^(NSDictionary *response, BOOL status) {
}];
finished_content
Swift
MPPush.shared.finishedContent(withProperties: postDict) { (response, status) in }
Objective C
[[MPPush shared] finishedContentWithProperties:postDict completionHandler:^(NSDictionary *response, BOOL status) {
}];