To add IntelliSuggest Tracking in Magento 1 you'll need to edit three template files. You'll want to add the following code snippets to the end of the each of the following template files. Be sure to replace YOUR_SITE_ID with your Searchspring Site ID.
app/design/frontend/TEMPLATENAME/default/template/catalog/product/view.phtml
<script type="text/javascript" src="//cdn.searchspring.net/intellisuggest/is.min.js"></script>
<script type="text/javascript">
try{
var product_code = "<?php echo $_product->getSku() ?>";
IntelliSuggest.init({siteId:'YOUR_SITE_ID', context:'Product/' + product_code, seed:product_code});
IntelliSuggest.viewItem({sku:product_code});
} catch(err) {}
</script>
app/design/frontend/TEMPLATENAME/default/template/checkout/cart.phtml
<?php
$intellisuggestCart = array();
try {
$intellisuggestSession = Mage::getSingleton('checkout/session');
foreach($intellisuggestSession->getQuote()->getAllItems() as $intellisuggestItem) {
if($intellisuggestItem->getPrice() > 0) {
$intellisuggestCart[] = array(
'sku' => Mage::getModel('catalog/product')->load($intellisuggestItem->getProductId())->getSku(),
'qty' => $intellisuggestItem->getQty(),
'price' => $intellisuggestItem->getPrice()
);
}
}
} catch (Exception $e) {}
?>
<script type="text/javascript" src="//cdn.searchspring.net/intellisuggest/is.min.js"></script>
<script type="text/javascript">
try{
var ss_seeds = [];
<?php foreach($intellisuggestCart as $intellisuggestItem): ?>
ss_seeds.push("<?php echo $intellisuggestItem['sku'] ?>");
<?php endforeach; ?>
IntelliSuggest.init({siteId:'YOUR_SITE_ID', context:'Basket/', seed:ss_seeds});
<?php foreach($intellisuggestCart as $intellisuggestItem): ?>
IntelliSuggest.haveItem({
sku: "<?php echo $intellisuggestItem['sku'] ?>",
qty: <?php echo $intellisuggestItem['qty'] ?>,
price: <?php echo $intellisuggestItem['price'] ?>
});
<?php endforeach; ?>
IntelliSuggest.inBasket();
} catch(err) {}
</script>
app/design/frontend/TEMPLATENAME/default/template/checkout/success.phtml
<?php
$intellisuggestCart = array();
try {
$intellisuggestOrder = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
foreach($intellisuggestOrder->getItemsCollection() as $intellisuggestItem) {
if($intellisuggestItem->getPrice() > 0) {
$intellisuggestCart[] = array(
'sku' => Mage::getModel('catalog/product')->load($intellisuggestItem->getProductId())->getSku(),
'qty' => 1,
'price' => $intellisuggestItem->getPrice()
);
}
}
} catch (Exception $e) {}
?>
<script type="text/javascript" src="//cdn.searchspring.net/intellisuggest/is.min.js"></script>
<script type="text/javascript">
try{
IntelliSuggest.init({siteId:'YOUR_SITE_ID'});
<?php foreach($intellisuggestCart as $intellisuggestItem): ?>
IntelliSuggest.haveItem({
sku:"<?php echo $intellisuggestItem['sku'] ?>",
qty:"<?php echo $intellisuggestItem['qty'] ?>",
price:"<?php echo $intellisuggestItem['price'] ?>"
});
<?php endforeach ?>
IntelliSuggest.inSale();
} catch(err) {}
</script>
Comments
0 comments
Please sign in to leave a comment.