Q & A JScript API

Written By Devin O'Neill ()

Updated at April 17th, 2025

Defaults:

Client Name: Enter Client' Name

Site Id: Annex Cloud will provide the Site ID

Implementation steps for Q&A module:

Call to CURL and Call to js file:

  • Put the below code on the specific page, where you want to display Q&A Tab.
  • It contains the div and CURL.
  • After putting the div it is necessary to place the CURL.
URL Path http://s23.socialannex.com/v4/process/get_data_curl.php
Parameters: siteID={site_id}&sa_p_img_url={product_image_url}&sa_p_url={product_url}&sa_p_price={product_price}&sa_p_name={product_name}&sa_p_id={product_id}
Method: GET
Example: http://s23.socialannex.com/v4/process/get_data_curl.php?siteID=4711340&sa_p_img_url=//example.com/product.jpg&sa_p_url=//example.com/product.php&sa_p_price=30.12&sa_p_name=poloshirt&sa_p_id=987679P
Response: Social Q and A Question and Answers html of product
Code Explanation:
  1. Need to execute above URL using http request call.
  2. Pass all requested parameter to the request call as GET request
  3. <div id="socialannex"></div>

This div is needed to add in outer of response html.

  1. After the request call add the following jscall, replace all #(hash) tag with actual value
<script src="//s23.socialannex.com/v4/js/s23-main-curl.js"></script>
<script type="text/javascript">
window.s23AsyncInit = function()
{
varbuildProductDetails= {
sa_p_url:window.location.href,
sa_p_img_url:" #PRODUCT_IMAGE_URL",
sa_p_name:" #PRODUCT_NAME",
sa_p_id:" #PRODUCT_ID",
sa_p_price:" #PRODUCT_PRICE"
}
S23Obj.init({
siteID: ENTER_SITE_ID,
saGetProdDetails:buildProductDetails
});
S23Obj.targetId = 'socialannex';
};
</script>

Note:

  • First add targeted div on client page ( ex <div id=”socialannex”>)
  • Place curl call inside this targeted div
  • Call js script after this div close and pass name of div id to js file (S23Obj.targetId ='socialannex';)

To display Questions and Answers count:

  •  Place following div, where you want to display the Questions & Answers count.
    <div id="sa_s23_qa_count"></div>

Add Sales Tracking Pixel On Order Confirmation Page:

  • On the order confirmation page, please add the following script.
 <script src="//c.socialannex.com/c-sale-track/?site_id=ENTER_SITE_ID&order_id=ORDER_ID&sale_amount=SALE_AMOUNT&email_id=EMAIL&coupon=COUPON&exclude_products=ProductInfoJsonArray"></script>

Note: In the above code replace ENTER_SITE_ID with the site id provided by the Social Annex (for staging & production sites).

To the above code, you will need to pass the following parameters:

  • ORDER_ID: Pass the user’s order id.
  • SALE_AMOUNT: Pass the total sale amount for the order placed by the users.The total amount should be without currency symbol. E.g. If the total sale amount is $78.31, then pass 78.31 only.
  • EMAIL: Pass user’s email address
  • COUPON: Pass the coupon code used by the user.
  • ProductInfoJsonArray: Create a Json array for the products information & passed that Json array to exclude_products parameter.

Following is the example of Json array:

varproductinfo = '{"1":
 {
"id":<Product ID/SKU>,
"price":<Product Price>,
"qty":<Product Qunatity>,
"product_name":"<Product Name>",
"product_url":"<Product URL>",
"product_image_url":"<Product Image Url>",
"category_id":"<Product Category Id>",
"category_name":"<Product Category Name>"
 },
"2":
 {
"id":<Product ID/SKU>,
"price":<Product Price>,
"qty":<Product Qunatity>,
"product_name":"<Product Name>",
"product_url":"<Product URL>",
"product_image_url":"<Product Image Url>",
"category_id":"<Product Category Id>",
"category_name":"<Product Category Name>"
 }
}';