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.
This method generates a Monetate ID and returns it as a string. You can store this ID locally for future use.
Reports an event to Monetate. This allows data to later be used for decisions within Monetate. Use this method to report events.
This method must be run in a thread.
Parameters:
- context is name of the event. (Required)
- events is the event data. (Required)
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.
Parameters:
- context is name of the event. (Required)
- events is the event data. (Required)
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.
Parameters:
- actionType is 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.
Parameter:
- actionType is 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.
Parameters:
- requestID is the request ID for the API.
- includeReporting indicates whether the response will have impression reporting data.
- arrActionTypes is the type of actions you want to request. You can specify multiple actions in an array to handle.
Parameters:
- actionTypes is the type of action you want to request. You can specify one action or multiple actions in an array to handle.
- includeReports indicates whether the response will have impression reporting data.
The following example specifies a single action.
The following example specifies multiple actions.
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.
Parameters:
- actionType is the type of action you want to request. You can specify multiple actions in an array to handle.
- context is name of the event.
- eventData is the data associated with the event.
- includeReporting indicates whether the response will have impression reporting data.
Parameters:
- actionType is the type of action you want to request. You can specify multiple actions in an array to handle.
- context is name of the event.
- eventData is the data associated with the event.
- includeReporting indicates whether the response will have impression reporting data.
Parameters:
- context is name of the event.
- requestID is the request ID for the API.
- includeReporting indicates whether the response will have impression reporting data.
- arrActionTypes is the type of actions you want to request. You can specify multiple actions in an array to handle.
- event is the data associated with the event.
Parameters:
- actionTypes is the type of action you want to request. You can specify one action or multiple actions in an array to handle.
- context is name of the event.
- event is the data associated with the event.
- includeReports indicates whether the response will have impression reporting data.
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
You can also capture the method response in a variable:
You can also capture the method response in a variable:
Updates the customerId within the User object.
Parameter:
- customerId is a string containing the customer ID. (Required)