Create Social Proof Actions
Social proof is a demonstration that other people have purchased or found value in a product or service. This demonstration helps the product or service stand out from others and makes the customer more likely to purchase it. These demonstrations often reflect existing customer behavior. For example, labelling a product as a bestseller is a social proof demonstration.
You can set up a handler for Omnichannel Social Proof actions 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 social proof data that you can then handle in code.
You must first create an Omnichannel Social Proof action in the Monetate platform for the methods to reference. Refer to Configure an Omnichannel Social Proof Action in the Monetate Knowledge Base for instructions.
Make note of the WHO settings because they correspond to events your code listens for. The example experience in this article uses the following WHO settings:
- IP address is 1.0.0.2
- Screen height is at least 500 pixels and screen width is at least 300 pixels
Also make note of the Social Proof type that you're creating.
The full code examples fulfill these conditions and will trigger the Social Proof action.
This method adds event data to the SDK's internal stack.
The parameters are as follows:
- context is name of the event.
- events is the event data.
The parameters are as follows:
- context is name of the event.
- events is the event data.
The parameters are as follows:
- context is name of the event. (Required)
- event is the event data. (Required)
The parameters are as follows:
- context is name of the event. (Required)
- event is the event data. (Required)
You can use this method multiple times to add all the necessary events for an experience you want to trigger. The example code uses multiple method calls to fulfill the experience requirements.
This method sends the defined events to Monetate to trigger an experience. If the events fulfill the WHO settings and the other required conditions of an experience, that experience is triggered. A JSON object containing the experience response is then returned.
The parameter is 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.
- includeReporting indicates whether the response will have impression reporting data.
The parameter is 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.
- includeReporting indicates whether the response will have impression reporting data.
The parameters are as follows:
- requestID is the request ID for the API.
- 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.
The parameters are as follows:
- 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 code examples are for each type of Social Proof messaging.
Viewed Product Full Code Example
This Social Proof type displays the message on products as determined by the number of times customers viewed a specific product detail page.
This Social Proof type requires the ContextPageView event to be added.
You must handle the getActions method in a Thread or AsyncTask. To update the main thread, you can use either Handler or runOnUiThread. This full code example uses Thread and Handler to update the main thread and change the UI.
Carted Product Full Code Example for Product Detail Pages
This Social Proof type displays the message on products most frequently added to a cart. To target product detail pages, you must add the ContextProductDetailView event.
You must handle the getActions method in a Thread or AsyncTask. To update the main thread, you can use either Handler or runOnUiThread. This full code example uses Thread and Handler to update the main thread and change the UI.
Carted Product Full Code Example for Pages Displaying Multiple Product IDs
This code example is for displaying a Social Proof message on the products most frequently added to a cart on page types that contain multiple product IDs, such as product category listings, search results pages, and cart pages. To target multi-PID pages, you must add the ProductThumbnailView event.
You must handle the getActions method in a Thread or AsyncTask. To update the main thread, you can use either Handler or runOnUiThread. This full code example uses Thread and Handler to update the main thread and change the UI.
Purchased Product Full Code Example for Product Detail Pages
This Social Proof type displays a message on products most frequently purchased. To target product detail pages, you must add the ContextProductDetailView event.
You must handle the getActions method in a Thread or AsyncTask. To update the main thread, you can use either Handler or runOnUiThread. This full code example uses Thread and Handler to update the main thread and change the UI.
Purchased Product Full Code Example for Pages Displaying Multiple Product IDs
This Social Proof type displays a message on products most frequently purchased. To target page types that contain multiple product IDs—such as product category listings, search results pages, and cart pages—you must add the ProductThumbnailView event.
You must handle the getActions method in a Thread or AsyncTask. To update the main thread, you can use either Handler or runOnUiThread. This full code example uses Thread and Handler to update the main thread and change the UI.
Recommended Product Full Code Example
This Social Proof type uses a recommendation strategy to determine and display a message on products the customer is most likely to purchase. You must add the ContextProductDetailView event.
You must handle the getActions method in a Thread or AsyncTask. To update the main thread, you can use either Handler or runOnUiThread. This full code example uses Thread and Handler to update the main thread and change the UI.
Inventory Full Code Example for Product Detail Pages
This Social Proof type displays a message on products based on your current inventory, which may indicate that a product is popular due to limited inventory count. To target product detail pages, you must add the ContextProductDetailView event.
You must handle the getActions method in a Thread or AsyncTask. To update the main thread, you can use either Handler or runOnUiThread. This full code example uses Thread and Handler to update the main thread and change the UI.
Inventory Full Code Example for Pages Displaying Multiple Product IDs
This Social Proof type displays a message on products based on your current inventory, which may indicate that a product is product due to limited inventory count. To target page types that contain multiple product IDs—such as product category listings, search results pages, and cart pages—you must add the ProductThumbnailView event.
You must handle the getActions method in a Thread or AsyncTask. To update the main thread, you can use either Handler or runOnUiThread. This full code example uses Thread and Handler to update the main thread and change the UI.