SDK Methods

The following methods are available to use in the Monetate SDK. All methods are part of the personalization class.

For parameters that require event names, refer to SDK Event and Action Types for syntax.

generateMonetateId

This method generates a Monetate ID and returns it as a string. You can store this ID locally for future use.

React Native
React Web
iOS
Android
generateMonetateId Method


Code Example

React Native
React Web
iOS
Android
generateMonetateId Method Example


report

Reports an event to Monetate. This allows data to later be used for decisions within Monetate. Use this method to report events.

React Native
React Web
iOS
Android
report Method


The parameters are as follows:

Parameter

Required

Description

context

Yes

The name of the event

events

Yes

The event data

Code Example

React Native
React Web
iOS
Android
report Method Example


addEvent

This method adds event data to the SDK's internal stack. Use this method to add events to the stack that you intend to use to trigger experiences. You can use multiple calls of this method to add multiple events to stack. Use this method with getActionsData when an experience requires data from more than one event.

React Native
React Web
iOS
Android
addEvent Method


The parameters are as follows:

Parameter

Required

Description

context

Yes

The name of the event

events

Yes

The event data

Code Example

React Native
React Web
iOS
Android
addEvent Method Example


getActionsData

Requests an experience decision from Monetate based off the action type. You can specify multiple action types in an array to get multiple responses.

The experience decision depends on event data reported using addEvent calls. Use addEvent to add report all of the relevant events before you use this method to request a decision.

React Native
React Web
iOS
Android
getActionsData Method


The parameters are as follows:

Parameter

Description

actionType

The type of action you want to request. You can specify one action or multiple actions in an array to handle.

includeReporting

Indicates whether the response will have impression reporting data.

Code Examples

The following example specifies a single action.

React Native
React Web
iOS
Android
getActionsData Method Example


The following example specifies multiple actions.

React Native
React Web
iOS
Android
getActionsData Method Example with Multiple Actions


getActions

Reports an event and immediately requests a decision from Monetate. Use this method if an experience you want to trigger requires a single event. This method returns a JSON object that includes the response data.

The response data can then be used in your application. For example, you can use this method to obtain data to display as a banner on a page.

React Native
React Web
iOS
Android
getActions Method


The parameters are as follows:

Parameter

Description

actionType

The type of action you want to request. You can specify multiple actions in an array to handle.

context

The name of the event.

eventData

The data associated with the event.

includeReporting

Indicates whether the response will have impression reporting data

Code Example

React Native
React Web
iOS
Android
getActions Method Example


flush

Immediately sends all event data that are currently queued. Use this method if you want to report an event immediately. This method returns a response of success or failure.

This method might throw the following exceptions that you must handle:

  • InterruptedException
  • ExecutionException
  • TimeoutException
React Native
React Web
iOS
Android
flush Method


Code Example

React Web
React Native
iOS
Android
flush Method Example


You can also capture the method response in a variable:

flush Method Reponse Example


setCustomerId

Updates the customerId within the User object.

React Native
React Web
iOS
Android
setCustomerId Method


The parameter is as follows:

  • customerId is a string containing the customer ID. (Required)

Code Example

React Native
React Web
iOS
Android
setCustomerId Method Example