Question

I am trying to add Google Trust Badge to my magento store. I tried to search extension on Magento website, but I couldn't find one. Do I need to just paste the below code to the products and checkout page or I have to make changes to it? I will be very thankful if someone can guide me to right direction.

<!-- BEGIN: Google Trusted Store -->
<script type="text/javascript">
  var gts = gts || [];

  gts.push(["id", "54785"]);
  gts.push(["google_base_offer_id", "ITEM_PRODUCT_SEARCH_ID"]);
  gts.push(["google_base_subaccount_id", "ITEM_PRODUCT_SEARCH_ACCOUNT_ID"]);
  gts.push(["google_base_country", "ITEM_PRODUCT_SEARCH_COUNTRY"]);
  gts.push(["google_base_language", "ITEM_PRODUCT_SEARCH_LANGUAGE"]);

  (function() {
    var scheme = (("https:" == document.location.protocol) ? "https://" : "http://");
    var gts = document.createElement("script");
    gts.type = "text/javascript";
    gts.async = true;
    gts.src = scheme + "www.googlecommerce.com/trustedstores/gtmp_compiled.js";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(gts, s);
  })();
</script>
<!-- END: Google Trusted Store -->


<!-- START Trusted Stores Order -->
<div id="gts-order" style="display:none;">

  <!-- start order and merchant information -->
  <span id="gts-o-id">MERCHANT_ORDER_ID</span>
  <span id="gts-o-domain">MERCHANT_ORDER_DOMAIN</span>
  <span id="gts-o-email">CUSTOMER_EMAIL</span>
  <span id="gts-o-country">CUSTOMER_COUNTRY</span>
  <span id="gts-o-currency">CURRENCY</span>
  <span id="gts-o-total">ORDER_TOTAL</span>
  <span id="gts-o-discounts">ORDER_DISCOUNTS</span>
  <span id="gts-o-shipping-total">ORDER_SHIPPING</span>
  <span id="gts-o-tax-total">ORDER_TAX</span>
  <span id="gts-o-est-ship-date">ORDER_EST_SHIP_DATE</span>
  <span id="gts-o-has-preorder">HAS_BACKORDER_PREORDER</span>
  <span id="gts-o-has-digital">HAS_DIGITAL_GOODS</span>
  <!-- end order and merchant information -->

  <!-- start repeated item specific information -->
  <!-- item example: this area repeated for each item in the order -->
  <span class="gts-item">
    <span class="gts-i-name">ITEM_NAME</span>
    <span class="gts-i-price">ITEM_PRICE</span>
    <span class="gts-i-quantity">ITEM_QUANTITY</span>
    <span class="gts-i-prodsearch-id">ITEM_PRODUCT_SEARCH_ID</span>
    <span class="gts-i-prodsearch-store-id">ITEM_PRODUCT_SEARCH_ACCOUNT_ID</span>
    <span class="gts-i-prodsearch-country">ITEM_PRODUCT_SEARCH_COUNTRY</span>
    <span class="gts-i-prodsearch-language">ITEM_PRODUCT_SEARCH_LANGUAGE</span>
  </span>
  <!-- end item 1 example -->
  <!-- end repeated item specific information -->

</div>
<!-- END Trusted Stores -->
Was it helpful?

Solution

There has since been a Magento extension released by Google themselves: http://www.magentocommerce.com/magento-connect/google-trusted-stores-3308.html

OTHER TIPS

Implementing Google Trusted Stores: #3 Add the JavaScript to Your Site:

Google actually wants you to put the first part on every page of your site. Rather than do this in a template file you can add it to the Footer > Miscellaneous HTML in System > Configuration > General > Design. I removed ITEM_PRODUCT_SEARCH_ID and ITEM_PRODUCT_SEARCH_ACCOUNT_ID, but feel free to edit your product page to add this data. Here's the code:

<!-- BEGIN: Google Trusted Store -->
<script type="text/javascript">
  var gts = gts || [];

  gts.push(["id", "54785"]);
  gts.push(["google_base_country", "US"]);
  gts.push(["google_base_language", "en"]);

  (function() {
    var scheme = (("https:" == document.location.protocol) ? "https://" : "http://");
    var gts = document.createElement("script");
    gts.type = "text/javascript";
    gts.async = true;
    gts.src = scheme + "www.googlecommerce.com/trustedstores/gtmp_compiled.js";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(gts, s);
  })();
</script>
<!-- END: Google Trusted Store -->

Screenshot of Magento System / Config / Design / Footer HTML

The rest of the code only needs to be on the Checkout Success page (app/design/frontend/{your}/{theme}/template/checkout/success.phtml). We need to load the order to grab the customer's email, country, and order data. You'll need to implement logic to determine whether or not any items are on backorder, whether any of the items are downloads, and when the items will be shipped. Add this anywhere in that file:

<?php
    $orderId = $this->getOrderId();
    $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
    $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
    $address = $order->getShippingAddress();
    $backorder = false; // some backorder logic
    $download = false; // some download logic
    $shipDate = new Zend_Date(); // some logic to determine ship date
?>
<!-- START Trusted Stores Order -->
<div id="gts-order" style="display:none;">

<!-- start order and merchant information -->
<span id="gts-o-id"><?php echo $orderId; ?></span>
<span id="gts-o-domain">{www.yourstore.com}</span>
<span id="gts-o-email"><?php echo htmlentities($customer->getEmail()); ?></span>
<span id="gts-o-country"><?php echo htmlentities($address->getCountryId()); ?></span>
<span id="gts-o-currency">USD</span>
<span id="gts-o-total"><?php echo $order->getGrandTotal(); ?></span>
<span id="gts-o-discounts">-<?php echo $order->getDiscountAmount(); ?></span>
<span id="gts-o-shipping-total"><?php echo $order->getShippingAmount(); ?></span>
<span id="gts-o-tax-total"><?php echo $order->getTaxAmount(); ?></span>
<span id="gts-o-est-ship-date"><?php echo $shipDate->toString('yyyy-MM-dd'); ?></span>
<span id="gts-o-has-preorder"><?php echo $backorder ? 'Y' : 'N'; ?></span>
<span id="gts-o-has-digital"><?php echo $download ? 'Y' : 'N'; ?></span>
<!-- end order and merchant information -->

<!-- start repeated item specific information -->
<?php foreach ($order->getAllItems() as $item): ?>
<span class="gts-item">
<span class="gts-i-name"><?php echo htmlentities($item->getName()); ?></span>
<span class="gts-i-price"><?php echo $item->getBasePrice(); ?></span>
<span class="gts-i-quantity"><?php echo (int)$item->getQtyOrdered(); ?></span>
<span class="gts-i-prodsearch-country">US</span>
<span class="gts-i-prodsearch-language">en</span>
</span>
<?php endforeach; ?>
<!-- end repeated item specific information -->

</div>
<!-- END Trusted Stores -->

You can insert that code at the bottom of app/design/frontend/default/USED_TEMPLATE/template/checkout/onepage.phtml to have it appear on the final checkout page.

You need to fill the variables, using the Magento-functions and output them. For example:

// Magento .phtml-style
<?php $cart = Mage::getSingleton( 'checkout/cart' ); ?>
<span class="gts-i-quantity"><?php echo $cart->getItemsCount(); ?></span>`

Or you go the long way, using Magento hooks in an own extension to present the Google-snippet wherever you want, without the need to implement it in the templates.

The code definitely needs to be on the checkout success page in the app folder (app/design/frontend/yourtheme/template/checkout/success.phtml). I found my answer here for magento badge implementation, but just like several answers suggest it is LOGIC that it is important and it is usually different for every store depending on the extension and custom dev you are running.

    <!– START Google Trusted Stores Order –>
<div id=”gts-order” style=”display:none;” translate=”no”>

<!– start order and merchant information –>
<span id=”gts-o-id”><?php echo $orderId; ?></span>
<span id=”gts-o-domain”>[INSERT URL (www.example.com)]</span>
<span id=”gts-o-email”><?php echo htmlentities($customer->getEmail()); ?></span>
<span id=”gts-o-country”><?php echo htmlentities($address->getCountryId()); ?></span>
<span id=”gts-o-currency”>[USD]</span>
<span id=”gts-o-total”><?php echo round_and_kep($order->getGrandTotal()); ?></span>
<span id=”gts-o-discounts”>[CALL IT OUT WITH CODE – use 0 if no discounts]</span>
<span id=”gts-o-shipping-total”><?php echo round_and_kep($order->getShippingAmount()); ?></span>
<span id=”gts-o-tax-total”><?php echo round_and_kep($order->getTaxAmount()); ?></span>
<span id=”gts-o-est-ship-date”><?php echo $shipDate->toString(‘yyyy-MM-dd’); ?></span>
<span id=”gts-o-est-delivery-date”><?php echo $shipDate->toString(‘yyyy-MM-dd’); ?></span>
<span id=”gts-o-has-preorder”><?php echo $backorder ? ‘Y’ : ‘N'; ?></span>
<span id=”gts-o-has-digital”><?php echo $download ? ‘Y’ : ‘N'; ?></span>
<!– end order and merchant information –>

<!– start repeated item specific information –>
<!– item example: this area repeated for each item in the order –>
<span class=”gts-item”>
<span class=”gts-i-name”><?php echo htmlentities($item->getName()); ?></span>
<span class=”gts-i-price”><?php echo round_and_kep($item->getBasePrice()); ?></span>
<span class=”gts-i-quantity”><?php echo (int)$item->getQtyOrdered(); ?></span>
<span class=”gts-i-prodsearch-id”>[ITEM_GOOGLE_SHOPPING_ID]</span>
<span class=”gts-i-prodsearch-store-id”>[YOUR STORE ID GIVEN TO YOU BY GOOGLE]</span>
<span class=”gts-i-prodsearch-country”>US</span>
<span class=”gts-i-prodsearch-language”>en</span>
</span>
<!– end item 1 example –>
<!– end repeated item specific information –>

</div>
<!– END Google Trusted Stores Order –>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top