When users take particular actions in your mobile apps—open push notifications, complete their profiles, close in-app messages, etc.—Iterable's React Native SDK can save corresponding events, of custom or pre-defined types, to their Iterable profiles. This guide describes how to do this, which gives your marketing team more data to use when segmenting users or setting up workflows.
Table of contents
Identify the user
Before you call the methods described below, identify your app's user so that Iterable knows which profile to update.
Push notification and in-app message events
Iterable automatically tracks various in-app message and push notification-related events, but you can also use Iterable's React Native SDK to track them manually. To learn more, read Push Notifications with Iterable's React Native SDK and In-App Messages with Iterable's React Native SDK
Tracking purchases
To create a purchase
event on a user's Iterable profile, call the static
trackPurchase
method on the Iterable
class.
-
Method declaration:
static trackPurchase( total: number, items: Array<IterableCommerceItem>, dataFields: any | undefined )
Parameter Name Description total
The total cost of the purchase. items
The items included in the purchase. dataFields
Descriptive data to store on the purchase
event.Represent each item in the purchase with an
IterableCommerceItem
object. This class has four fields:id
(string),name
(string),price
(number),quantity
(number), and a constructor to initialize those values.NOTE
Iterable does not sum the
price
fields for the various items in the purchase. Instead, it uses thetotal
that you provide. -
Description:
This method creates a
purchase
event on the user's Iterable profile. -
Example:
Iterable.trackPurchase( 8.98, [ new IterableCommerceItem("12345", "Spoon", 3.99, 1), new IterableCommerceItem("67890", "Fork", 4.99, 1) ], { "promotion": "2020 winter sale" } );
This example creates a
purchase
event on the current user's Iterable profile.
Tracking custom events
To save an event of a custom type to a user's Iterable profile, call the static
trackEvent
method on the Iterable
class.
-
Method declaration:
static trackEvent(name: string, dataFields: any | undefined)
Parameter Name Description name
The eventName
for the custom event.dataFields
Descriptive data to store on the event. -
Description:
This method creates a custom event (
eventType
ofcustomEvent
) witheventName
set to the value you provide in thename
parameter, and stores it on the current user's profile. -
Example:
Iterable.trackEvent( "completedOnboarding", { "includedProfilePhoto": true, "favoriteColor": "red" } );
This call creates an event such as following on the user's Iterable profile:
{ "eventName": "completedOnboarding", "eventType": "customEvent", "email": "docs@iterable.com", "createdAt": "2020-07-14 04:06:04 +00:00", "eventUpdatedAt": "2020-07-14 04:06:04 +00:00", "dataFields": { "includedProfilePhoto": true, "favoriteColor": "red" }, "itblInternal": { "documentCreatedAt": "2020-07-14 04:06:04 +00:00", "documentUpdatedAt": "2020-07-14 04:06:04 +00:00" } }
Comments
0 comments
Article is closed for comments.