Actions

Create a Data Collection Action

In some cases when you trigger an action, you might not want to alter your site's content while still retaining the customer data involved with the action. In these cases, you can perform a Data Collect action.

You can set up a handler for a data collection action by using two methods. The addEvent method defines the events that can trigger the action. The getActionsData method is then used as the trigger and requests the decision based on the defined events. getActionsData then returns a JSON object containing customer data.

While this data does not affect your site's content, you can use it for other cases elsewhere in code.

addEvent

This method adds a local event to the SDK's internal stack.

React Native
React Web
iOS
Android
addEvent Method


The parameters are as follows:

  • context is name of the event.
  • event is the event data.

You can use this method multiple times to add all the necessary events for an experience that you might want to trigger. The example code uses multiple method calls to fulfill the experience requirements.

Code Example

React Native
React Web
iOS
Android
addEvent Example


getActionsData

This method sends the defined events to Monetate to trigger an experience. If the events fulfill the WHO settings of an experience, then that experience is triggered. A JSON object containing the experience response is then returned.

React Native
React Web
iOS
Android
getActionsData Method


The parameters are as follows:

  • actionType 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.

Use DataCollection as the action type for this method. includeReports must be set to true for this method to return data.

Code Example

React Native
React Web
iOS
Android
getActionsData Example


Full Code Example

React Native
React Web
iOS
Android
Data Collection Action Full Example