Create an Image-Based Badging Action
Monetate's SDK product badging action allows clients to apply a small promotional image displayed atop the product image to specific items on product listing pages and product detail pages to draw site visitors' attention to those items. A product badge frequently appears as a digital promotional sticker displayed atop the product image to indicate that the item is a bestseller or a top-rated product. These labels serve as customer endorsements, allowing shoppers to more quickly locate popular products on a page.
You can set up a handler for Omnichannel badging 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 experience based on the defined events. getActionsData then returns a JSON object containing badging image data that you can then handle in code.
You must first create an Omnichannel badging action in the Monetate platform for the methods to reference. Refer to Configure an Omnichannel Product Badging Action in the Monetate Knowledge Base for instructions.
This action uses Product Thumbnail View as an event listener. To accomplish this, you must configure a Thumbnail's product ID = action condition. Make note of this product ID so that you can pass the appropriate ID in code.
Optionally, you can add other conditions to this action. If you do, make note of those so that you can pass those as relevant events.
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.
For an Omnichannel badging action, use the ContextProductThumbnailView event as your context. Pass a list of product IDs that you want to set up a badge for as your events data.
If you added other action conditions to the Omnichannel badging action, then use additional calls of this method to handle them with the appropriate events and data.
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.
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.
Use OmniChannelImageBadging as the action type for this method.
This code triggers the configured Omnichannel badging experience. Customize the example code as you see fit.
An example of the JSON data returned from getActionsData is below. Handle this response in your code accordingly to render the data in your UI as you see fit.