---
title: Create Social Proof Actions
slug: sdks/social-proof
description: How to create Omnichannel Social Proof actions in the React Web, React Native, iOS, and Android versions of the Monetate SDK
image:  https://archbee-image-uploads.s3.amazonaws.com/ceIfEvQHzQk1IVxoRWUh7/K9eTL4jKm7UQINb6zNziJ-20250912-181225.png
docTags: 
createdAt: 2024-06-13T19:35:56.459Z
---

:::BlockQuote
**Note :**&#x54;his legacy flow remains supported for backward compatibility.New integrations are recommended to use the Context Layer–based getActions() approach. After each section you will find new contextlayer based approach
:::

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.&#x20;

You can set up a handler for Omnichannel Social Proof actions using two methods. The [addEvent](docId\:F5SIeJXaS3hi38DaXdVPy) method defines the events that can trigger the action. The [getActionsData](docId\:F5SIeJXaS3hi38DaXdVPy) 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.

## Prerequisites

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](https://docs.monetate.com/docs/create-an-omnichannel-social-proof-action) in the Monetate Knowledge Base for instructions.

Make note of the [WHO settings](docId\:uI0Or7GoerH9r_wUMbc6m) 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.

## addEvent

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

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
addEvent Method

```javascript
addEvent(context: EventTypes, events: ContextData): void
```
:::

The parameters are as follows:

- `context` is name of the event.
- `events` is the event data.
::::

::::Tab{title="React Web"}
:::CodeblockTabs
addEvent Method

```javascript
addEvent(context: EventTypes, events: ContextData): void
```
:::

The parameters are as follows:

- `context` is name of the event.
- `events` is the event data.
::::

::::Tab{title="iOS"}
:::CodeblockTabs
addEvent Method

```swift
addEvent(context: <ContextEnum>, event: <MEvent?>)
```
:::

The parameters are as follows:

- `context` is name of the event. (Required)
- `event` is the event data. (Required)
::::

::::Tab{title="Android"}
:::CodeblockTabs
addEvent Method

```java
public void addEvent(String context, Object event)
```
:::

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.

### Code Example

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
addEvent Example

```javascript
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});
```
:::
::::

::::Tab{title="React Web"}
:::CodeblockTabs
addEvent Example

```javascript
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});
```
:::
::::

::::Tab{title="iOS"}
:::CodeblockTabs
addEvent Example

```swift
objPersonalization.addEvent(context: .ScreenSize, event: ScreenSize(height: 1000, width: 400))

objPersonalization.addEvent(context: .IpAddress, event: IPAddress(ipAddress: "192.168.1.52")) 
```
:::
::::

::::Tab{title="Android"}
:::CodeblockTabs
addEvent Example

```java
IpAddress ipAddress = new IpAddress();
ipAddress.setIpAddress("10.0.0.2");

ScreenSize screenSize = new ScreenSize();
screenSize.setHeight(23);
screenSize.setWidth(34);

PageView pageView = new PageView();
pageView.setPageType("Cartpage");
pageView.setUrl("https://www.monetate.com");

// addEvent
personalization.addEvent(EventTypes.ContextScreenSize, screenSize);
personalization.addEvent(EventTypes.ContextIpAddress, ipAddress);
personalization.addEvent(EventTypes.ContextPageView, pageView);
```
:::
::::
:::::

## getActionsData

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.

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
getActionsData Method

```javascript
getActionsData(actionType: Array<string>, includeReporting?: boolean) : Promise<any>
```
:::

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.
::::

::::Tab{title="React Web"}
:::CodeblockTabs
getActionsData Method

```javascript
getActionsData(actionType: Array<string>, includeReporting?: boolean) : Promise<any>
```
:::

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.
::::

::::Tab{title="iOS"}
:::CodeblockTabs
getActionsData Method

```swift
getActionsData(requestId: <String>, includeReporting: <Bool>, arrActionTypes: <[String]>
```
:::

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.
::::

::::Tab{title="Android"}
:::CodeblockTabs
getActionsData Method

```java
public String getActionsData(String[] actionTypes, boolean includeReports)
```
:::

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.
::::
:::::

### Code Example

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
getActionsData Example

```javascript
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:SocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="React Web"}
:::CodeblockTabs
getActionsData Example

```javascript
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:SocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="iOS"}
:::CodeblockTabs
getActionsData Example

```swift
objPersonalization.getActionsData(
  requestId: "123456 ", includeReporting: false,
  arrActionTypes: ["monetate:action:SocialProofDataV2"]
)
.on { res in
  if res.status == 200 {
    let data = JSON(res.data as Any)
    for item in data["data"]["responses"].arrayValue {
      if item["requestId"].string == res.requestId {
        for socialProof in item["actions"].arrayValue {
          self.handleSocialProofs(res: socialProof)
        }
      }
    }
  } else {
    // Error Handling
  }
}
```
:::
::::

::::Tab{title="Android"}
:::CodeblockTabs
getActionsData Example

```java
String responseData = personalization.getActionsData(new String[]{"monetate:action:SocialProofDataV2"},true);
```
:::
::::
:::::

The following code examples are for each type of Social Proof messaging.

::::::ExpandableHeading{isOpen="true"}
## Viewed Product Full Code Example

:::BlockQuote
**Note :**&#x54;his legacy flow remains supported for backward compatibility.New integrations are recommended to use the Context Layer–based getActions() approach.[ check below](https://developer.monetate.com/sdks/social-proof#yocJi)
:::

This Social Proof type displays the message on products as determined by the number of times customers viewed a specific product detail page.

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
Viewed-Based Social Proof Action Example

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextPageView, {
  url: "http://www.monetate.com/index.html",
  pageType: "Home"
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="React Web"}
:::CodeblockTabs
Viewed-Based Social Proof Action Example

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextPageView, {
  url: "http://www.monetate.com/index.html",
  pageType: "Home"
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="iOS"}
:::hint{type="info"}
This Social Proof type requires the `ContextPageView` event to be added.
:::

:::CodeblockTabs
Viewed-Based Social Proof Action Example

```swift
// Add Context / Events
//-------------------------------------------------------------------------
objPersonalization.addEvent(context: .ScreenSize, event: ScreenSize(height: 1000, width: 400))
objPersonalization.addEvent(context: .IpAddress, event: IPAddress(ipAddress: "192.168.1.52"))
objPersonalization.addEvent(
  context: .PageView,
  event: PageView(pageType: "PDP", path: "n/a", url: "n/a", categories: [], breadcrumbs: []))

// Get Social Proof Actions
// ----------------------------------------------------
objPersonalization.getActionsData(
  requestId: "123456", includeReporting: false,
  arrActionTypes: ["monetate:action:SocialProofDataV2"]
)
.on { res in
  if res.status == 200 {
    let data = JSON(res.data as Any)
    for item in data["data"]["responses"].arrayValue {
      if item["requestId"].string == res.requestId {
        for socialProof in item["actions"].arrayValue {
          self.handleSocialProofs(res: socialProof)
        }
      }
    }
  } else {
    // Error Handling
  }
}
```
:::
::::

::::Tab{title="Android"}
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.

:::CodeblockTabs
Viewed-Based Social Proof Action Example

```java
Personalization personalization = new personalization(user, account);

// Events/context data
Product product = new Product();
product.setProductId("97");
product.setSku("SKU");
ProductDetailView productDetailView = new ProductDetailView();
productDetailView.setProducts(new Product[]
{
  product
});

PageView pageView = new PageView();
pageView.setPageType("Cartpage");
pageView.setUrl("https://www.monetate.com");

// addEvent
personalization.addEvent(EventTypes.ContextProductDetailView, productDetailView);
personalization.addEvent(EventTypes.ContextPageView, pageView);

// getActionsData
String responseData;
new Thread(new Runnable()
{

  @Override
  public void run()
  {

    // Get the responseData using getActionsData
    responseData = personalization.getActionsData("monetate:action:SocialProofDataV2");

    // Once you receive the responseData from getActionsData, use the Handler and parse the required data 
    new Handler(Looper.getMainLooper()).post(new Runnable()
    {
      @Override
      public void run()
      {

        // Parse the received responseData, get the requiredData from it and use it accordingly
        try
        {
          // Example: textView.setText(requiredData);
        }
        catch (Exception ex)
        {
          // Catch any exception that occured while parsing 
          ex.printStackTrace();
        }

      }
    });
  }
}).start();
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Viewed Product Full Code Example using ContextLayer&#x20;

:::BlockQuote
**Note:**&#x54;he Context-based getActions() flow replaces the need to manually use addEvent and getActionsData when evaluating actions.
:::

<font color="#15803D">**Supported SDK Versions**</font>

- <font color="#4283c7">**Android**</font>: 1.0.6-A or later&#x20;
- <font color="#4283c7">**React-Native**</font>: 1.0.6-RN or later&#x20;
- <font color="#4283c7">**Web**</font>: 1.0.6-W or later&#x20;
- <font color="#4283c7">**iOS**</font>**:** 2026.01.06 or later

:::::Tabs
::::Tab{title="iOS"}
:::CodeblockTabs
Viewed-Based Social Proof Action Example

```swift
let contextObj = ContextObj()  
        let productsSample = [
            Product(productId: "PROD001", sku: "SKU001")
        ]
        contextObj.addProductDetails(productsSample)
        contextObj.addPageDetails(pageType: "PDP", path: "n/a", url: "n/a", categories: [], breadcrumbs: [])
        
        
        objPersonalization.getActions(context: contextObj, arrActionTypes: ["monetate:action:SocialProofDataV2"], includeReporting: false)
            .on(success: { (actions) in
                    self.handleSocialProof(actions: actions)
        })
```
:::
::::

::::Tab{title="Android"}


:::CodeblockTabs
Viewed-Based Social Proof Action Example

```java
            Context context = new Context();
			context.addProductDetails(new Product[] {new Product("97", "sku")});
			context.addPageDetails("Cartpage", "https://www.monetate.com", new String[] {"categories-here"},new String[] {"breadcrums--here"},"test/path");	
			personalization.getActions(context, new String[] {"monetate:action:SocialProofDataV2"}, false,new ActionsCallback() {
				@Override
				public void onSuccess(String actions) {
					System.out.println("Action data :"+actions);		
				}
				
				@Override
				public void onError(Exception e) {
					System.out.println("Ex :"+e);	
				}
			});
		
```
:::
::::

::::Tab{title="React-Native"}
:::CodeblockTabs
Viewed-Based Social Proof Action Example

```typescript
const context = new Context();
context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::

::::Tab{title="Web"}
:::CodeblockTabs
Viewed-Based Social Proof Action Example

```typescript
const context = new Context();
context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Carted Product Full Code Example for Product Detail Pages

:::BlockQuote
**Note :**&#x54;his legacy flow remains supported for backward compatibility. New integrations are recommended to use the Context Layer–based getActions() approach.[ check below](https://developer.monetate.com/sdks/social-proof#bBtVy)
:::

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.

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
Carted-Based Social Proof Action Example—Product Detail Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductDetailView, {
  products: [
    {
      productId: "94",
      sku: "sku",
    },
  ],
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="React Web"}
:::CodeblockTabs
Carted-Based Social Proof Action Example—Product Detail Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductDetailView, {
  products: [
    {
      productId: "94",
      sku: "sku",
    },
  ],
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="iOS"}
:::CodeblockTabs
Carted-Based Social Proof Action Example—Product Detail Pages

```swift
// Add Context / Events
//-------------------------------------------------------------------------
objPersonalization.addEvent(context: .ScreenSize, event: ScreenSize(height: 1000, width: 400))
objPersonalization.addEvent(context: .IpAddress, event: IPAddress(ipAddress: "192.168.1.52"))
objPersonalization.addEvent(
  context: .ProductDetailView,
  event: ProductDetailView(products: [Product(productId: "BackP_010", sku: "Blue_BackP_010")]))

// Get Social Proof Actions
// ----------------------------------------------------
objPersonalization.getActionsData(
  requestId: "123456", includeReporting: false,
  arrActionTypes: ["monetate:action:SocialProofDataV2"]
)
.on { res in
  if res.status == 200 {
    let data = JSON(res.data as Any)
    for item in data["data"]["responses"].arrayValue {
      if item["requestId"].string == res.requestId {
        for socialProof in item["actions"].arrayValue {
          self.handleSocialProofs(res: socialProof)
        }
      }
    }
  } else {
    // Error Handling
  }
}

```
:::
::::

::::Tab{title="Android"}
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.

:::CodeblockTabs
Carted-Based Social Proof Action Example—Product Detail Pages

```java
// Add Context and Events
Product product = new Product();
product.setProductId("97");
product.setSku("SKU");
ProductDetailView productDetailView = new ProductDetailView();
productDetailView.setProducts(new Product[]
{
  product
});
PageView pageView = new PageView();
pageView.setPageType("Cartpage");
pageView.setUrl("https://www.monetate.com");

// addEvent
personalization.addEvent(EventTypes.ContextProductDetailView, productDetailView);
personalization.addEvent(EventTypes.ContextPageView, pageView);

// Get Social Proof Actions
// getActionsData
String responseData;
new Thread(new Runnable()
{
  @Override
  public void run()
  {
    // Gets the responseData using getActionsData
    responseData = personalization.getActionsData(new String[]
    {
      "monetate:action:SocialProofDataV2"
    }, true);
    // Once you receive the responseData from getActionsData, use the Handler and parse the required data from it 
    new Handler(Looper.getMainLooper()).post(new Runnable()
    {
      @Override
      public void run()
      {
        // Parse the received responseData, get the requiredData from it and use it accordingly
        try
        {
          // Example: textView.setText(requiredData);
        }
        catch (Exception ex)
        {
          // Catch any exception that occurs while parsing 
          ex.printStackTrace();
        }
      }
    });
  }
}).start();
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Carted Product Full Code Example for Product Detail Pages using ContextLayer&#x20;

:::BlockQuote
**Note:**&#x54;he Context-based getActions() flow replaces the need to manually use addEvent and getActionsData when evaluating actions.
:::

<font color="#15803D">**Supported SDK Versions**</font>

- <font color="#4283c7">**Android**</font>: 1.0.6-A or later&#x20;
- <font color="#4283c7">**React-Native**</font>: 1.0.6-RN or later&#x20;
- <font color="#4283c7">**Web**</font>: 1.0.6-W or later&#x20;
- <font color="#4283c7">**iOS**</font>**:** 2026.01.06 or later

:::::Tabs
::::Tab{title="iOS"}
:::CodeblockTabs
Carted-Based Social Proof Action Example—Product Detail Pages

```swift
   let contextObj = ContextObj()
        
        let productsSample = [
            Product(productId: "PROD001", sku: "SKU001")
        ]
        contextObj.addProductDetails(productsSample)
        contextObj.addPageDetails(pageType: "PDP", path: "n/a", url: "n/a", categories: [], breadcrumbs: [])
    
        objPersonalization.getActions(context: contextObj, arrActionTypes: ["monetate:action:SocialProofDataV2"], includeReporting: false)
            .on(success: { (actions) in
                    self.handleSocialProof(actions: actions)
            })
    }
```
:::
::::

::::Tab{title="Android"}


:::CodeblockTabs
Carted-Based Social Proof Action Example—Product Detail Pages

```java
            Context context = new Context();
			context.addProductDetails(new Product[] {new Product("97", "sku")});
			context.addPageDetails("Cartpage", "https://www.monetate.com", new String[] {"categories-here"},new String[] {"breadcrums--here"},"test/path");	
		
			personalization.getActions(context, new String[] {"monetate:action:SocialProofDataV2"}, false,new ActionsCallback() {		
				@Override
				public void onSuccess(String actions) {
					System.out.println("Action data :"+actions);		
				}	
				@Override
				public void onError(Exception e) {
					System.out.println("Ex :"+e);	
				}
			});
		
```
:::
::::

::::Tab{title="React-Native"}
:::CodeblockTabs
Viewed-Based Social Proof Action Example

```typescript
const context = new Context();
context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::

::::Tab{title="Web"}


:::CodeblockTabs
Viewed-Based Social Proof Action Example

```typescript
const context = new Context();
context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Carted Product Full Code Example for Pages Displaying Multiple Product IDs

:::BlockQuote
**Note :**&#x54;his legacy flow remains supported for backward compatibility. New integrations are recommended to use the Context Layer–based getActions() approach.[ check below](https://developer.monetate.com/sdks/social-proof#Kh96R)
:::

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.

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
Carted-Based Social Proof Action Example—Multi-PID Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductThumbnailView, {
  "products": ["104","94","97" ] 
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="React Web"}
:::CodeblockTabs
Carted-Based Social Proof Action Example—Multi-PID Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductThumbnailView, {
  "products": ["104","94","97" ] 
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="iOS"}
:::CodeblockTabs
Carted-Based Social Proof Action Example—Multi-PID Pages

```swift
// Add Context / Events
//-------------------------------------------------------------------------
objPersonalization.addEvent(context: .ScreenSize, event: ScreenSize(height: 1000, width: 400))
objPersonalization.addEvent(context: .IpAddress, event: IPAddress(ipAddress: "192.168.1.52"))
objPersonalization.addEvent(
  context: .ProductThumbnailView,
  event: ProductThumbnailView(products: Set(["BackP_010", "BackP_011"])))

// Get Social Proof Actions
// ----------------------------------------------------
objPersonalization.getActionsData(
  requestId: "123456", includeReporting: false,
  arrActionTypes: ["monetate:action:SocialProofDataV2"]
)
.on { res in
  if res.status == 200 {
    let data = JSON(res.data as Any)
    for item in data["data"]["responses"].arrayValue {
      if item["requestId"].string == res.requestId {
        for socialProof in item["actions"].arrayValue {
          self.handleSocialProofs(res: socialProof)
        }
      }
    }
  } else {
    // Error Handling
  }
}
```
:::
::::

::::Tab{title="Android"}
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.

:::CodeblockTabs
Carted-Based Social Proof Action Example—Multi-PID Pages

```java
// Add Context and Events
ProductThumbnailView productThumbnailView = new ProductThumbnailView();
productThumbnailView.setProducts(new String[]
{
  "94",
  "97",
  "104"
});
PageView pageView = new PageView();
pageView.setPageType("Cartpage");
pageView.setUrl("https://www.monetate.com");

// addEvent
personalization.addEvent(EventTypes.ContextProductThumbnailView, productThumbnailView);
personalization.addEvent(EventTypes.ContextPageView, pageView);

// Get Social Proof Actions
// getActionsData
String responseData;
new Thread(new Runnable()
{
  @Override
  public void run()
  {
    // Gets the responseData using getActionsData
    responseData = personalization.getActionsData(new String[]
    {
      "monetate:action:SocialProofDataV2"
    }, true);
    // Once you receive the responseData from getActionsData, use the Handler and parse the required data from it 
    new Handler(Looper.getMainLooper()).post(new Runnable()
    {
      @Override
      public void run()
      {
        // Parse the received responseData, get the requiredData from it and use it accordingly
        try
        {
          // Example: textView.setText(requiredData);
        }
        catch (Exception ex)
        {
          // Catch any exception that occurs while parsing 
          ex.printStackTrace();
        }
      }
    });
  }
}).start();
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Carted Product Full Code Example for Pages Displaying Multiple Product IDs using ContextLayer&#x20;

:::BlockQuote
**Note:**&#x54;he Context-based getActions() flow replaces the need to manually use addEvent and getActionsData when evaluating actions.
:::

<font color="#15803D">**Supported SDK Versions**</font>

- <font color="#4283c7">**Android**</font>: 1.0.6-A or later&#x20;
- <font color="#4283c7">**React-Native**</font>: 1.0.6-RN or later&#x20;
- <font color="#4283c7">**Web**</font>: 1.0.6-W or later&#x20;
- <font color="#4283c7">**iOS**</font>**:** 2026.01.06 or later

:::::Tabs
::::Tab{title="iOS"}
:::CodeblockTabs
Carted-Based Social Proof Action Example—Multi-PID Pages

```swift
 let contextObj = ContextObj()
        contextObj.addProductThumbnailsData(["PROD001", "PROD002", "PROD003"])
        contextObj.addPageDetails(pageType: "PDP", path: "n/a", url: "n/a", categories: [], breadcrumbs: [])
        
        objPersonalization.getActions(context: contextObj, arrActionTypes: ["monetate:action:SocialProofDataV2"], includeReporting: false)
            .on(success: { (actions) in
                    self.handleSocialProof(actions: actions)
            })
    }
```
:::
::::

::::Tab{title="Android"}


:::CodeblockTabs
Carted-Based Social Proof Action Example—Multi-PID Pages

```java
            Context context = new Context();	
			context.addProductThumbnailsData(new String[] {"104", "94", "97"});
			context.addPageDetails("Cartpage", "https://www.monetate.com", new String[] {"categories-here"},new String[] {"breadcrums--here"},"test/path");
			personalization.getActions(context, new String[] {"monetate:action:SocialProofDataV2"}, false,new ActionsCallback() {	
				@Override
				public void onSuccess(String actions) {
					System.out.println("Action data :"+actions);
				}
				@Override
				public void onError(Exception e) {
					System.out.println("Ex :"+e);	
				}
			});
		
```
:::
::::

::::Tab{title="React-Native"}
:::CodeblockTabs{indent="2"}
Carted-Based Social Proof Action Example—Multi-PID Pages

```typescript
const context = new Context();
context
  .addProductThumbnailsData()
  .product([
    "prod_101",
    "prod_102",
    "prod_103"
  ]);
Personalization.getActions(
  ["monetate:action:OmniChannelImageBadging"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::

::::Tab{title="Web"}
:::CodeblockTabs{indent="2"}
Carted-Based Social Proof Action Example—Multi-PID Pages

```typescript
const context = new Context();
context
  .addProductThumbnailsData()
  .product([
    "prod_101",
    "prod_102",
    "prod_103"
  ]);
Personalization.getActions(
  ["monetate:action:OmniChannelImageBadging"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Purchased Product Full Code Example for Product Detail Pages

:::BlockQuote
**Note :**&#x54;his legacy flow remains supported for backward compatibility. New integrations are recommended to use the Context Layer–based getActions() approach.[ check below](https://developer.monetate.com/sdks/social-proof#cNog4)
:::

This Social Proof type displays a message on products most frequently purchased. To target product detail pages, you must add the `ContextProductDetailView` event.

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Product Detail Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductDetailView, {
  products: [{productId: "94",sku: "sku"}],
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="React Web"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Product Detail Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductDetailView, {
  products: [{productId: "94",sku: "sku"}],
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="iOS"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Product Detail Pages

```swift
// Add Context / Events
//-------------------------------------------------------------------------
objPersonalization.addEvent(context: .ScreenSize, event: ScreenSize(height: 1000, width: 400))
objPersonalization.addEvent(context: .IpAddress, event: IPAddress(ipAddress: "192.168.1.52"))
objPersonalization.addEvent(
  context: .ProductDetailView,
  event: ProductDetailView(products: [Product(productId: "BackP_010", sku: "Blue_BackP_010")]))

// Get Social Proof Actions
// ----------------------------------------------------
objPersonalization.getActionsData(
  requestId: "123456", includeReporting: false,
  arrActionTypes: ["monetate:action:SocialProofDataV2"]
)
.on { res in
  if res.status == 200 {
    let data = JSON(res.data as Any)
    for item in data["data"]["responses"].arrayValue {
      if item["requestId"].string == res.requestId {
        for socialProof in item["actions"].arrayValue {
          self.handleSocialProofs(res: socialProof)
        }
      }
    }
  } else {
    // Error Handling
  }
}
```
:::
::::

::::Tab{title="Android"}
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.

:::CodeblockTabs
Purchased-Based Social Proof Action Example—Product Detail Pages

```java
// Add Context and Events
Product product1 = new Product();
product1.setProductId("97");
product1.setSku("SKU");
ProductDetailView productDetailView = new ProductDetailView();
productDetailView.setProducts(new Product[]
{
  product1
});
PageView pageView = new PageView();
pageView.setPageType("Cartpage");
pageView.setUrl("https://www.monetate.com");

// addEvent
personalization.addEvent(EventTypes.ContextProductDetailView, productDetailView);
personalization.addEvent(EventTypes.ContextPageView, pageView);

// Get Social Proof Actions
// getActionsData
String responseData;
new Thread(new Runnable()
{
  @Override
  public void run()
  {
    // Gets the responseData using getActionsData
    responseData = personalization.getActionsData(new String[]
    {
      "monetate:action:SocialProofDataV2"
    }, true);
    // Once you receive the responseData from getActionsData, use the Handler and parse the required data from it 
    new Handler(Looper.getMainLooper()).post(new Runnable()
    {
      @Override
      public void run()
      {
        // Parse the received responseData, get the requiredData from it and use it accordingly
        try
        {
          // Example: textView.setText(requiredData);
        }
        catch (Exception ex)
        {
          // Catch any exception that occurs while parsing 
          ex.printStackTrace();
        }
      }
    });
  }
}).start();
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Purchased Product Full Code Example for Product Detail Pages using ContextLayer&#x20;

:::BlockQuote
**Note:**&#x54;he Context-based getActions() flow replaces the need to manually use addEvent and getActionsData when evaluating actions.
:::

<font color="#15803D">**Supported SDK Versions**</font>

- <font color="#4283c7">**Android**</font>: 1.0.6-A or later&#x20;
- <font color="#4283c7">**React-Native**</font>: 1.0.6-RN or later&#x20;
- <font color="#4283c7">**Web**</font>: 1.0.6-W or later&#x20;
- <font color="#4283c7">**iOS**</font>**:** 2026.01.06 or later

This Social Proof type displays a message on products most frequently purchased. To target product detail pages, you must add the `ContextProductDetailView` event.

:::::Tabs
::::Tab{title="iOS"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Product Detail Pages

```swift
 let contextObj = ContextObj()
        let productsSample = [
            Product(productId: "PROD001", sku: "SKU001")
        ]
        contextObj.addProductDetails(productsSample)
        contextObj.addPageDetails(pageType: "PDP", path: "n/a", url: "n/a", categories: [], breadcrumbs: [])
       
        objPersonalization.getActions(context: contextObj, arrActionTypes: ["monetate:action:SocialProofDataV2"], includeReporting: false)
            .on(success: { (actions) in
                    self.handleSocialProof(actions: actions)
            })
    

```
:::
::::

::::Tab{title="Android"}


:::CodeblockTabs
Purchased-Based Social Proof Action Example—Product Detail Pages

```java
            Context context = new Context();
			context.addProductDetails(new Product[] {new Product("97", "sku")});
			context.addPageDetails("Cartpage", "https://www.monetate.com", new String[] {"categories-here"},new String[] {"breadcrums--here"},"test/path");
				
			personalization.getActions(context, new String[] {"monetate:action:SocialProofDataV2"}, false,new ActionsCallback() {
				@Override
				public void onSuccess(String actions) {
					System.out.println("Action data :"+actions);				
				}
				@Override
				public void onError(Exception e) {
					System.out.println("Ex :"+e);	
				}
			});
```
:::
::::

::::Tab{title="React-Native"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Product Detail Pages

```typescript
const context = new Context();
context.
     addProductDetails().
     productId("123").
     productSKU("SKU-123")

personalization.ProductDetails();

context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::

::::Tab{title="Web"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Product Detail Pages

```typescript
const context = new Context();
context.
     addProductDetails().
     productId("123").
     productSKU("SKU-123")

personalization.ProductDetails();

context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Purchased Product Full Code Example for Pages Displaying Multiple Product IDs

:::BlockQuote
**Note :**&#x54;his legacy flow remains supported for backward compatibility. New integrations are recommended to use the Context Layer–based getActions() approach.[ check below](https://developer.monetate.com/sdks/social-proof#BxBFV)
:::

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.

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Multi-PID Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductThumbnailView, {
  "products": ["88","86","97" ] 
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="React Web"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Multi-PID Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductThumbnailView, {
  "products": ["88","86","97" ] 
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="iOS"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Multi-PID Pages

```swift
// Add Context / Events
//-------------------------------------------------------------------------
objPersonalization.addEvent(context: .ScreenSize, event: ScreenSize(height: 1000, width: 400))
objPersonalization.addEvent(context: .IpAddress, event: IPAddress(ipAddress: "192.168.1.52"))
objPersonalization.addEvent(
  context: .ProductThumbnailView,
  event: ProductThumbnailView(products: Set(["BackP_010", "BackP_011"])))

// Get Social Proof Actions
// ----------------------------------------------------
objPersonalization.getActionsData(
  requestId: "123456", includeReporting: false,
  arrActionTypes: ["monetate:action:SocialProofDataV2"]
)
.on { res in
  if res.status == 200 {
    let data = JSON(res.data as Any)
    for item in data["data"]["responses"].arrayValue {
      if item["requestId"].string == res.requestId {
        for socialProof in item["actions"].arrayValue {
          self.handleSocialProofs(res: socialProof)
        }
      }
    }
  } else {
    // Error Handling
  }
}
```
:::
::::

::::Tab{title="Android"}
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.

:::CodeblockTabs
Purchased-Based Social Proof Action Example—Multi-PID Pages

```java
// Add Context and Events
ProductThumbnailView productThumbnailView = new ProductThumbnailView();
productThumbnailView.setProducts(new String[]
{
  "94",
  "97",
  "104"
});
PageView pageView = new PageView();
pageView.setPageType("Cartpage");
pageView.setUrl("https://www.monetate.com");

// addEvent
personalization.addEvent(EventTypes.ContextProductThumbnailView, productThumbnailView);
personalization.addEvent(EventTypes.ContextPageView, pageView);

// Get Social Proof Actions
// getActionsData
String responseData;
new Thread(new Runnable()
{
  @Override
  public void run()
  {
    // Gets the responseData using getActionsData
    responseData = personalization.getActionsData(new String[]
    {
      "monetate:action:SocialProofDataV2"
    }, true);
    // Once you receive the responseData from getActionsData, use the Handler and parse the required data from it 
    new Handler(Looper.getMainLooper()).post(new Runnable()
    {
      @Override
      public void run()
      {
        // Parse the received responseData, get the requiredData from it and use it accordingly
        try
        {
          // Example: textView.setText(requiredData);
        }
        catch (Exception ex)
        {
          // Catch any exception that occurs while parsing 
          ex.printStackTrace();
        }
      }
    });
  }
}).start();
```
:::
::::
:::::
::::::

::::::ExpandableHeading
## Purchased Product Full Code Example for Pages Displaying Multiple Product IDs using ContextLayer

:::BlockQuote
**Note:**&#x54;he Context-based getActions() flow replaces the need to manually use addEvent and getActionsData when evaluating actions.
:::

<font color="#15803D">**Supported SDK Versions**</font>

- <font color="#4283c7">**Android**</font>: 1.0.6-A or later&#x20;
- <font color="#4283c7">**React-Native**</font>: 1.0.6-RN or later&#x20;
- <font color="#4283c7">**Web**</font>: 1.0.6-W or later&#x20;
- <font color="#4283c7">**iOS**</font>**:** 2026.01.06 or later

:::::Tabs
::::Tab{title="iOS"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Multi-PID Pages

```swift
  let contextObj = ContextObj()
        contextObj.addProductThumbnailsData(["PROD001", "PROD002", "PROD003"])
        contextObj.addPageDetails(pageType: "PDP", path: "n/a", url: "n/a", categories: [], breadcrumbs: [])
         
        objPersonalization.getActions(context: contextObj, arrActionTypes: ["monetate:action:SocialProofDataV2"], includeReporting: false)
            .on(success: { (actions) in
                    self.handleSocialProof(actions: actions)
            })
```
:::
::::

::::Tab{title="Android"}


:::CodeblockTabs
Purchased-Based Social Proof Action Example—Multi-PID Pages

```java
            Context context = new Context();	
			context.addProductThumbnailsData(new String[] {"104", "94", "97"});
			context.addPageDetails("Cartpage", "https://www.monetate.com", new String[] {"categories-here"},new String[] {"breadcrums--here"},"test/path");
			personalization.getActions(context, new String[] {"monetate:action:SocialProofDataV2"}, false,new ActionsCallback() {	
				@Override
				public void onSuccess(String actions) {
					System.out.println("Action data :"+actions);
				}
				@Override
				public void onError(Exception e) {
					System.out.println("Ex :"+e);	
				}
			});
		
```
:::
::::

::::Tab{title="React-Native"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Multi-PID Pages

```typescript
const context = new Context();
context
  .addProductThumbnailsData()
  .product([
    "prod_101",
    "prod_102",
    "prod_103"
  ]);

ontext
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::

::::Tab{title="Web"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Multi-PID Pages

```typescript
const context = new Context();
context
  .addProductThumbnailsData()
  .product([
    "prod_101",
    "prod_102",
    "prod_103"
  ]);

ontext
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Recommended Product Full Code Example

:::BlockQuote
**Note :**&#x54;his legacy flow remains supported for backward compatibility. New integrations are recommended to use the Context Layer–based getActions() approach.[ check below](https://developer.monetate.com/sdks/social-proof#I_rP0)
:::

This Social Proof type uses a [recommendation strategy](https://docs.monetate.com/docs/create-a-recommendation-strategy) to determine and display a message on products the customer is most likely to purchase. You must add the `ContextProductDetailView` event.

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
Recommendation Strategy-Based Social Proof Action Example

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductDetailView, {
  products: [{productId: "94",sku: "sku"}],
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="React Web"}
:::CodeblockTabs
Recommendation Strategy-Based Social Proof Action Example

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductDetailView, {
  products: [{productId: "94",sku: "sku"}],
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="iOS"}
:::CodeblockTabs
Recommendation Strategy-Based Social Proof Action Example

```swift
// Add Context / Events
//-------------------------------------------------------------------------
objPersonalization.addEvent(context: .ScreenSize, event: ScreenSize(height: 1000, width: 400))
objPersonalization.addEvent(context: .IpAddress, event: IPAddress(ipAddress: "192.168.1.52"))
objPersonalization.addEvent(
  context: .ProductDetailView,
  event: ProductDetailView(products: [Product(productId: "BackP_010", sku: "Blue_BackP_010")]))

// Get Social Proof Actions
// ----------------------------------------------------
objPersonalization.getActionsData(
  requestId: "123456", includeReporting: false,
  arrActionTypes: ["monetate:action:SocialProofDataV2"]
)
.on { res in
  if res.status == 200 {
    let data = JSON(res.data as Any)
    for item in data["data"]["responses"].arrayValue {
      if item["requestId"].string == res.requestId {
        for socialProof in item["actions"].arrayValue {
          self.handleSocialProofs(res: socialProof)
        }
      }
    }
  } else {
    // Error Handling
  }
}
```
:::
::::

::::Tab{title="Android"}
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.

:::CodeblockTabs
Recommendation Strategy-Based Social Proof Action Example

```java
// Add Context and Events
Product product1 = new Product();
product1.setProductId("97");
product1.setSku("SKU");
ProductDetailView productDetailView = new ProductDetailView();
productDetailView.setProducts(new Product[]
{
  product1
});
PageView pageView = new PageView();
pageView.setPageType("Cartpage");
pageView.setUrl("https://www.monetate.com");

// addEvent
personalization.addEvent(EventTypes.ContextProductDetailView, productDetailView);
personalization.addEvent(EventTypes.ContextPageView, pageView);

// Get Social Proof Actions
// getActionsData
String responseData;
new Thread(new Runnable()
{
  @Override
  public void run()
  {
    // Gets the responseData using getActionsData
    responseData = personalization.getActionsData(new String[]
    {
      "monetate:action:SocialProofDataV2"
    }, true);
    // Once you receive the responseData from getActionsData, use the Handler and parse the required data from it 
    new Handler(Looper.getMainLooper()).post(new Runnable()
    {
      @Override
      public void run()
      {
        // Parse the received responseData, get the requiredData from it and use it accordingly
        try
        {
          // Example: textView.setText(requiredData);
        }
        catch (Exception ex)
        {
          // Catch any exception that occurs while parsing 
          ex.printStackTrace();
        }
      }
    });
  }
}).start();
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Recommended Product Full Code Example using ContextLayer

:::BlockQuote
**Note:**&#x54;he Context-based getActions() flow replaces the need to manually use addEvent and getActionsData when evaluating actions.
:::

<font color="#15803D">**Supported SDK Versions**</font>

- <font color="#4283c7">**Android**</font>: 1.0.6-A or later&#x20;
- <font color="#4283c7">**React-Native**</font>: 1.0.6-RN or later&#x20;
- <font color="#4283c7">**Web**</font>: 1.0.6-W or later&#x20;
- <font color="#4283c7">**iOS**</font>**:** 2026.01.06 or later

:::::Tabs
::::Tab{title="iOS"}
:::CodeblockTabs
Recommendation Strategy-Based Social Proof Action Example

```swift
  let contextObj = ContextObj()
        let productsSample = [
            Product(productId: "PROD001", sku: "SKU001")
        ]
        contextObj.addProductDetails(productsSample)
        contextObj.addPageDetails(pageType: "PDP", path: "n/a", url: "n/a", categories: [], breadcrumbs: [])
        
        objPersonalization.getActions(context: contextObj, arrActionTypes: ["monetate:action:SocialProofDataV2"], includeReporting: false)
            .on(success: { (actions) in
                    self.handleSocialProof(actions: actions)
            })
    }
```
:::
::::

::::Tab{title="Android"}


:::CodeblockTabs
Recommendation Strategy-Based Social Proof Action Example

```java
            Context context = new Context();
			context.addProductDetails(new Product[] {new Product("97", "sku")});
			context.addPageDetails("Cartpage", "https://www.monetate.com", new String[] {"categories-here"},new String[] {"breadcrums--here"},"test/path");	
			personalization.getActions(context, new String[] {"monetate:action:SocialProofDataV2"}, false,new ActionsCallback() {	
				@Override
				public void onSuccess(String actions) {
					System.out.println("Action data :"+actions);		
				}		
				@Override
				public void onError(Exception e) {
					System.out.println("Ex :"+e);	
				}
			});
		
```
:::
::::

::::Tab{title="React-Native"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Product Detail Pages

```typescript
const context = new Context();
context.
     addProductDetails().
     productId("123").
     productSKU("SKU-123")

personalization.ProductDetails();

context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::

::::Tab{title="Web"}
:::CodeblockTabs
Purchased-Based Social Proof Action Example—Product Detail Pages

```typescript
const context = new Context();
context.
     addProductDetails().
     productId("123").
     productSKU("SKU-123")

personalization.ProductDetails();

context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Inventory Full Code Example for Product Detail Pages

:::BlockQuote
**Note :**&#x54;his legacy flow remains supported for backward compatibility. New integrations are recommended to use the Context Layer–based getActions() approach.[ check below](https://developer.monetate.com/sdks/social-proof#ga-A1)
:::

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.

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Product Detail Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductDetailView, {
  products: [{productId: "94",sku: "sku"}],
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="React Web"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Product Detail Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductDetailView, {
  products: [{productId: "94",sku: "sku"}],
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="iOS"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Product Detail Pages

```swift
// Add Context / Events
//-------------------------------------------------------------------------
objPersonalization.addEvent(context: .ScreenSize, event: ScreenSize(height: 1000, width: 400))
objPersonalization.addEvent(context: .IpAddress, event: IPAddress(ipAddress: "192.168.1.52"))
objPersonalization.addEvent(
  context: .ProductDetailView,
  event: ProductDetailView(products: [Product(productId: "BackP_010", sku: "Blue_BackP_010")]))

// Get Social Proof Actions
// ----------------------------------------------------
objPersonalization.getActionsData(
  requestId: "123456", includeReporting: false,
  arrActionTypes: ["monetate:action:SocialProofDataV2"]
)
.on { res in
  if res.status == 200 {
    let data = JSON(res.data as Any)
    for item in data["data"]["responses"].arrayValue {
      if item["requestId"].string == res.requestId {
        for socialProof in item["actions"].arrayValue {
          self.handleSocialProofs(res: socialProof)
        }
      }
    }
  } else {
    // Error Handling
  }
}
```
:::
::::

::::Tab{title="Android"}
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.

:::CodeblockTabs
Inventory-Based Social Proof Action Example—Product Detail Pages

```java
// Add Context and Events
Product product1 = new Product();
product1.setProductId("97");
product1.setSku("SKU");
ProductDetailView productDetailView = new ProductDetailView();
productDetailView.setProducts(new Product[]
{
  product1
});
PageView pageView = new PageView();
pageView.setPageType("Cartpage");
pageView.setUrl("https://www.monetate.com");

// addEvent
personalization.addEvent(EventTypes.ContextProductDetailView, productDetailView);
personalization.addEvent(EventTypes.ContextPageView, pageView);

// Get Social Proof Actions
// getActionsData
String responseData;
new Thread(new Runnable()
{
  @Override
  public void run()
  {
    // Gets the responseData using getActionsData
    responseData = personalization.getActionsData(new String[]
    {
      "monetate:action:SocialProofDataV2"
    }, true);
    // Once you receive the responseData from getActionsData, use the Handler and parse the required data from it 
    new Handler(Looper.getMainLooper()).post(new Runnable()
    {
      @Override
      public void run()
      {
        // Parse the received responseData, get the requiredData from it and use it accordingly
        try
        {
          // Example: textView.setText(requiredData);
        }
        catch (Exception ex)
        {
          // Catch any exception that occurs while parsing 
          ex.printStackTrace();
        }
      }
    });
  }
}).start();
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Inventory Full Code Example for Product Detail Pages using ContextLayer

:::BlockQuote
**Note:**&#x54;he Context-based getActions() flow replaces the need to manually use addEvent and getActionsData when evaluating actions.
:::

<font color="#15803D">**Supported SDK Versions**</font>

- <font color="#4283c7">**Android**</font>: 1.0.6-A or later&#x20;
- <font color="#4283c7">**React-Native**</font>: 1.0.6-RN or later&#x20;
- <font color="#4283c7">**Web**</font>: 1.0.6-W or later&#x20;
- <font color="#4283c7">**iOS**</font>**:** 2026.01.06 or later

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.&#x20;

:::::Tabs
::::Tab{title="iOS"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Product Detail Pages

```swift
      let contextObj = ContextObj()
        let productsSample = [
            Product(productId: "PROD001", sku: "SKU001")
        ]
        contextObj.addProductDetails(productsSample)
        contextObj.addPageDetails(pageType: "PDP", path: "n/a", url: "n/a", categories: [], breadcrumbs: [])
     
        objPersonalization.getActions(context: contextObj, arrActionTypes: ["monetate:action:SocialProofDataV2"], includeReporting: false)
            .on(success: { (actions) in
                    self.handleSocialProof(actions: actions)
            })
    }
```
:::
::::

::::Tab{title="Android"}


:::CodeblockTabs
Inventory-Based Social Proof Action Example—Product Detail Pages

```java
            Context context = new Context();
			context.addProductDetails(new Product[] {new Product("97", "sku")});
			context.addPageDetails("Cartpage", "https://www.monetate.com", new String[] {"categories-here"},new String[] {"breadcrums--here"},"test/path");	
			personalization.getActions(context, new String[] {"monetate:action:SocialProofDataV2"}, false,new ActionsCallback() {	
			
				@Override
				public void onSuccess(String actions) {
					System.out.println("Action data :"+actions);		
				}
				
				@Override
				public void onError(Exception e) {
					System.out.println("Ex :"+e);
				}
			});
```
:::
::::

::::Tab{title="React-Native"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Product Detail Pages

```typescript
const context = new Context();
context.
     addProductDetails().
     productId("123").
     productSKU("SKU-123")

personalization.ProductDetails();

context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::

::::Tab{title="Web"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Product Detail Pages

```typescript
const context = new Context();
context.
     addProductDetails().
     productId("123").
     productSKU("SKU-123")

personalization.ProductDetails();

context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::
:::::
::::::

::::::ExpandableHeading{isOpen="true"}
## Inventory Full Code Example for Pages Displaying Multiple Product IDs&#x20;

:::BlockQuote
**Note :**&#x54;his legacy flow remains supported for backward compatibility. New integrations are recommended to use the Context Layer–based getActions() approach.[ check below](https://developer.monetate.com/sdks/social-proof#uL8of)
:::

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.

:::::Tabs
::::Tab{title="React Native"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Multi-PID Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductThumbnailView, {
  "products": ["90","91","92" ] 
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="React Web"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Multi-PID Pages

```javascript
// Add Context / Events
//-------------------------------------------------------------------------
personalizationInstance.addEvent(EventTypes.ContextScreenSize, { width: 23, height: 34 });

personalizationInstance.addEvent(EventTypes.ContextIpAddress, {
  ipAddress: "10.0.0.2",
});

personalizationInstance.addEvent(EventTypes.ContextProductThumbnailView, {
  "products": ["90","91","92" ] 
});

// Get Social Proof Actions
// ----------------------------------------------------
let socialProofData;
personalizationInstance
  .getActionsData("monetate:action:OmniSocialProofDataV2")
  .then(res => {
    socialProofData = res[0].actions;
  })
  .catch(error => {
    console.warn('Error!', error);
  });
```
:::
::::

::::Tab{title="iOS"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Multi-PID Pages

```swift
// Add Context / Events
//-------------------------------------------------------------------------
objPersonalization.addEvent(context: .ScreenSize, event: ScreenSize(height: 1000, width: 400))
objPersonalization.addEvent(context: .IpAddress, event: IPAddress(ipAddress: "192.168.1.52"))
objPersonalization.addEvent(
  context: .ProductThumbnailView,
  event: ProductThumbnailView(products: Set(["BackP_010", "BackP_011"])))

// Get Social Proof Actions
// ----------------------------------------------------
objPersonalization.getActionsData(
  requestId: "123456", includeReporting: false,
  arrActionTypes: ["monetate:action:SocialProofDataV2"]
)
.on { res in
  if res.status == 200 {
    let data = JSON(res.data as Any)
    for item in data["data"]["responses"].arrayValue {
      if item["requestId"].string == res.requestId {
        for socialProof in item["actions"].arrayValue {
          self.handleSocialProofs(res: socialProof)
        }
      }
    }
  } else {
    // Error Handling
  }
}
```
:::
::::

::::Tab{title="Android"}
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.

:::CodeblockTabs
Inventory-Based Social Proof Action Example—Multi-PID Pages

```java
// Add Context and Events
ProductThumbnailView productThumbnailView = new ProductThumbnailView();
productThumbnailView.setProducts(new String[]
{
  "104",
  "94",
  "97"
});
PageView pageView = new PageView();
pageView.setPageType("Cartpage");
pageView.setUrl("https://www.monetate.com");

// addEvent
personalization.addEvent(EventTypes.ContextProductThumbnailView, productThumbnailView);
personalization.addEvent(EventTypes.ContextPageView, pageView);

// Get Social Proof Actions
// getActionsData
String responseData;
new Thread(new Runnable()
{
  @Override
  public void run()
  {
    // Gets the responseData using getActionsData
    responseData = personalization.getActionsData(new String[]
    {
      "monetate:action:SocialProofDataV2"
    }, true);
    // Once you receive the responseData from getActionsData, use the Handler and parse the required data from it 
    new Handler(Looper.getMainLooper()).post(new Runnable()
    {
      @Override
      public void run()
      {
        // Parse the received responseData, get the requiredData from it and use it accordingly
        try
        {
          // Example: textView.setText(requiredData);
        }
        catch (Exception ex)
        {
          // Catch any exception that occurs while parsing 
          ex.printStackTrace();
        }
      }
    });
  }
}).start();
```
:::
::::
:::::


::::::

::::::ExpandableHeading{isOpen="true"}
## Inventory Full Code Example for Pages Displaying Multiple Product IDs using Context Layer&#x20;

:::BlockQuote
**Note:**&#x54;he Context-based getActions() flow replaces the need to manually use addEvent and getActionsData when evaluating actions.
:::

**Supported SDK version**

- **Android**: 1.0.6-A or later&#x20;
- **iOS**: 2026.01.06 or later&#x20;

:::::Tabs
::::Tab{title="iOS"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Multi-PID Pages

```swift
     let contextObj = ContextObj()
        contextObj.addProductThumbnailsData(["PROD001", "PROD002", "PROD003"])
        contextObj.addPageDetails(pageType: "PDP", path: "n/a", url: "n/a", categories: [], breadcrumbs: [])
        
        objPersonalization.getActions(context: contextObj, arrActionTypes: ["monetate:action:SocialProofDataV2"], includeReporting: false)
            .on(success: { (actions) in
                    self.handleSocialProof(actions: actions)
            })
    }

```
:::
::::

::::Tab{title="Android"}


:::CodeblockTabs
Inventory-Based Social Proof Action Example—Multi-PID Pages

```java
            Context context = new Context();	
			context.addProductThumbnailsData(new String[] {"104", "94", "97"});
			context.addPageDetails("Cartpage", "https://www.monetate.com", new String[] {"categories-here"},new String[] {"breadcrums--here"},"test/path");
			personalization.getActions(context, new String[] {"monetate:action:SocialProofDataV2"}, false,new ActionsCallback() {	
				@Override
				public void onSuccess(String actions) {
					System.out.println("Action data :"+actions);
				}
				@Override
				public void onError(Exception e) {
					System.out.println("Ex :"+e);	
				}
			});
		
```
:::
::::

::::Tab{title="React-Native"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Multi-PID Pages

```typescript
const context = new Context();
context
  .addProductThumbnailsData()
  .product([
    "prod_101",
    "prod_102",
    "prod_103"
  ]);


personalization.ProductDetails();

context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::

::::Tab{title="web"}
:::CodeblockTabs
Inventory-Based Social Proof Action Example—Multi-PID Pages

```typescript
const context = new Context();
context.
     addProductDetails().
     productId("123").
     productSKU("SKU-123")

personalization.ProductDetails();

context
    .addPageDetails()
    .url("www.monetate.com")
    .path(monetate.com)
    .pageType("home")
    .breadcrumbs(["Home"])
    .categories(["Homepage"]);

Personalization.getActions(
  ["monetate:action:OmnichannelJson"], 
  context)
  .then((res: any) => console.log("Action === 1 res", res));
```
:::
::::
:::::


::::::

