Skip to main content

Magento Integration (Store Reviews)

This article guides you through placing code on your Magento site for store reviews.

Please start by following along with our master integration guide here.

From there, you can follow the steps below to see where to place the code specifically on Magento.

Step 1 - Add the Store Survey Code

Place the Thank you page code on your theme’s success.phtml template file via FTP access.

Common Locations:

  • app/design/frontend/{your_vendor_name}/{your_theme_name}/Magento_Checkout/templates/success.phtml

  • app/design/frontend/{your_vendor_name}/{your_theme_name}/Magento_InventoryInStorePickupFrontend/templates/success.phtml

Thank You Page Code (Store Reviews code)

<!-- Shopper Approved TY Page Code -->
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($block->getOrderId());
if ($order->getCustomerIsGuest() && $order->getBillingAddress()) {
$customerName = $order->getBillingAddress()->getName();
//Use $order->getCustomerName() as a last resort
if (!trim($customerName)) {
$customerName = $order->getCustomerName();
}
} else {
$customerName = $order->getCustomerName();
}
$customerEmail = $order->getCustomerEmail();
$countryCode = $order->getShippingAddress()->getCountryId();
$customerCountry = $objectManager->create('\Magento\Directory\Model\Country')->load($countryCode)->getName();
$orderItems = $order->getAllVisibleItems();
$orderItemData = [];
?>

<script type="text/javascript">var siteID = xxxx; var siteToken = "xxxxx"; var sa_values = { "site":siteID, "token":siteToken, 'orderid':'<?= $block->getOrderId(); ?>', 'name':'<?= $customerName; ?>', 'email':'<?= $customerEmail; ?>', 'country':'<?= $customerCountry; ?>', 'state':'<?= $block->escapeHtml($order->getShippingAddress()->getRegionCode()); ?>' }; function saLoadScript(src) { var js = window.document.createElement("script"); js.src = src; js.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(js); } var d = new Date(); saLoadScript("https://www.shopperapproved.com/thankyou/rate/" + siteID + ".js?d=" + d.getTime()); </script>
<!-- END Shopper Approved TY Page Code -->

Note: Please update the siteID and siteToken values to your own.

Once you collect store reviews, you will want to place a dedicated store reviews page on your site to display those reviews.
​​

Step 2 - Place a Test Order

Next, place a test order to verify your integration is working as expected. Our How to Test Your Shopper Approved Survey guide walks you through the process, including how to verify the order information, submit a test review, and test the post-fulfillment survey.

Step 3 - Add a Store Reviews Page

Location: Magento Dashboard > Content > Pages > Add New Page

  1. Enter the ‘Page Title’ and ‘Edit with Page Builder’ to integrate the reviews page code.

2. Add the reviews page code snippet inside the Page Builder.

Example Output:

3. Add a Reviews page link in the footer.

Go to your Magento Dashboard > Content > Blocks > and select the available footer blocks where you want to add the reviews page link.

For this example, select the ‘Footer Cms Content’ block, edit it with Page Builder to add the HTML code for the reviews link.

Example Output:

Step 4 - Add a Seal

Go to your Magento Dashboard > Content > Blocks > and choose the available footer and header blocks where you want to display your seal.

Step 5 - Add a Rotating Widget

Placement is typically above the footer on the home page.

  1. Go to Magento Dashboard > Content > Pages > URL Key: home

2. Get the rotating widget code from the SA dashboard and add it through the HTML widget on the page builder.

Example Output:

If you are also collecting product reviews, continue here for how to add the product code to your Magento site.

If you are using Answerbase (Q&A), continue here for how to add the code to your Magento site.


If you have any questions, please contact [email protected].

Did this answer your question?