Actions
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 sdk methods method defines the events that can trigger the action the sdk methods 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 in the monetate knowledge base for instructions make note of the monetate core components 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 addevent method addevent(context eventtypes, events contextdata) void the parameters are as follows context is name of the event events is the event data addevent method addevent(context eventtypes, events contextdata) void the parameters are as follows context is name of the event events is the event data addevent method addevent(context \<contextenum>, event \<mevent?>) the parameters are as follows context is name of the event (required) event is the event data (required) addevent method 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 addevent example personalizationinstance addevent(eventtypes contextscreensize, { width 23, height 34 }); personalizationinstance addevent(eventtypes contextipaddress, { ipaddress "10 0 0 2", }); addevent example personalizationinstance addevent(eventtypes contextscreensize, { width 23, height 34 }); personalizationinstance addevent(eventtypes contextipaddress, { ipaddress "10 0 0 2", }); addevent example objpersonalization addevent(context screensize, event screensize(height 1000, width 400)) objpersonalization addevent(context ipaddress, event ipaddress(ipaddress "192 168 1 52")) addevent example 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 getactionsdata method 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 getactionsdata method 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 getactionsdata method 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 getactionsdata method 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 getactionsdata example let socialproofdata; personalizationinstance getactionsdata("monetate\ action\ socialproofdatav2") then(res => { socialproofdata = res\[0] actions; }) catch(error => { console warn('error!', error); }); getactionsdata example let socialproofdata; personalizationinstance getactionsdata("monetate\ action\ socialproofdatav2") then(res => { socialproofdata = res\[0] actions; }) catch(error => { console warn('error!', error); }); getactionsdata example 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 } } getactionsdata example string responsedata = personalization getactionsdata(new string\[]{"monetate\ action\ socialproofdatav2"},true); 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 viewed based social proof action example // 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); }); viewed based social proof action example // 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); }); this social proof type requires the contextpageview event to be added viewed based social proof action example // 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 } } 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 viewed based social proof action example 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(); 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 carted based social proof action example—product detail pages // 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); }); carted based social proof action example—product detail pages // 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); }); carted based social proof action example—product detail pages // 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 } } 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 based social proof action example—product detail pages // 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(); 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 carted based social proof action example—multi pid pages // 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); }); carted based social proof action example—multi pid pages // 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); }); carted based social proof action example—multi pid pages // 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 } } 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 based social proof action example—multi pid pages // 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(); 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 purchased based social proof action example—product detail pages // 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); }); purchased based social proof action example—product detail pages // 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); }); purchased based social proof action example—product detail pages // 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 } } 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 based social proof action example—product detail pages // 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(); 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 purchased based social proof action example—multi pid pages // 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); }); purchased based social proof action example—multi pid pages // 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); }); purchased based social proof action example—multi pid pages // 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 } } 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 based social proof action example—multi pid pages // 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(); 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 recommendation strategy based social proof action example // 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); }); recommendation strategy based social proof action example // 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); }); recommendation strategy based social proof action example // 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 } } 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 recommendation strategy based social proof action example // 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(); 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 inventory based social proof action example—product detail pages // 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); }); inventory based social proof action example—product detail pages // 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); }); inventory based social proof action example—product detail pages // 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 } } 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 based social proof action example—product detail pages // 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(); 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 inventory based social proof action example—multi pid pages // 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); }); inventory based social proof action example—multi pid pages // 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); }); inventory based social proof action example—multi pid pages // 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 } } 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 based social proof action example—multi pid pages // 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();