Magento CE or EE Criteo retargeting New OneTag
**Home Page - code :**
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript"> window.criteo_q = window.criteo_q || []; window.criteo_q.push( { event: "setAccount", account: **Your Account Number**}, { event: "setCustomerId", id: "<?php if(Mage::getSingleton('customer/session')->isLoggedIn()) {$customerData = Mage::getSingleton('customer/session')->getCustomer();echo $customerData->getId();
}?>"}, { event: "setSiteType", type: "d"}, { event: "viewHome"} ); </script>
**Listing Page Code :**
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
window.criteo_q = window.criteo_q || [];
window.criteo_q.push(
{ event: "setAccount", account: **Your Account Number**},
{ event: "setCustomerId", id: "<?php if(Mage::getSingleton('customer/session')->isLoggedIn()) {$customerData = Mage::getSingleton('customer/session')->getCustomer();echo $customerData->getId();
}?>"},
{ event: "setSiteType", type: "d"},
{ event: "viewList", item: [<?php
$cat_id = Mage::getModel('catalog/layer')->getCurrentCategory()->getId();
$category = Mage::getModel('catalog/category')->load($cat_id);
$products = $category->getProductCollection()
->addCategoryFilter($category)
->addAttributeToSort('entity_id','desc')
->addAttributeToFilter('type_id','configurable')
->addAttributeToSelect('sku');
$products->setPage(1, 3);
$skus = '';
foreach ( $products as $_product ):
$skus .= '"'.$_product->getSku().'",';
endforeach;
$skus = substr($skus,0,-1);
print($skus);
?>], keywords: "<?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?>" } ); </script>
Product Page Code :
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
window.criteo_q = window.criteo_q || []; window.criteo_q.push(
{ event: "setAccount", account: **Your Account Number**},
{ event: "setCustomerId", id: "<?php if(Mage::getSingleton('customer/session')->isLoggedIn()) {$customerData = Mage::getSingleton('customer/session')->getCustomer();echo $customerData->getId();
}?>"},
{ event: "setSiteType", type: "d"},
{ event: "viewItem", item: "<?php echo $_product->getSKU() ?>" }
);
</script>
**Basket Page Code :**
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
window.criteo_q = window.criteo_q || [];
window.criteo_q.push(
{event: "setAccount", account: **Your Account Number**},
{event: "setCustomerId", id: "<?php if(Mage::getSingleton('customer/session')->isLoggedIn()) {$customerData = Mage::getSingleton('customer/session')->getCustomer();echo $customerData->getId();
}?>"},
{event: "setSiteType", type: "d"},
{event: "viewBasket", item: [
<?php
$count = 0;
$cartLines = Mage::helper('checkout/cart')->getCart()->getItems();
foreach ($cartLines as $cartLine):
$count++;
$product = Mage::getModel('catalog/product')->load($cartLine->getProductId());
if ($product->getSpecialPrice()) {
$price = $product->getSpecialPrice();
} else {
$price = $product->getPrice();
}
/* Get Configurable Sku from Simple product SKU/ID.
* If there is no configurable/simple product set up, then just use the standard Sku display
* */
$parentId = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($cartLine->getProductId());
$configurableProductSku = Mage::getModel('catalog/product')->load($parentId)->getSku();
if ($configurableProductSku) {
$IdString .= $configurableProductSku;
}
else {
$idString .= $cartLine->getSku();
}
// $IdString .= $cartLine->getSku();
$PriceString .= $price;
$quantityString .= (int) $cartLine->getQty();
?>
<?php if( $count == count($cartLines)): ?>
{ id: "<?php echo $IdString; ?>", price: <?php echo number_format($PriceString,2,'.',' ')?>, quantity: <?php echo $quantityString ?> }
<?php else: ?>
{ id: "<?php echo $IdString; ?>", price: <?php echo number_format($PriceString,2,'.',' ')?>, quantity: <?php echo $quantityString ?> },
<?php endif; ?>
<?php
$IdString = '';
$PriceString = '';
$quantityString ='';
endforeach;
?>
]}); </script>
**Success Page Code:**
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
window.criteo_q = window.criteo_q || [];
window.criteo_q.push( {event: "setAccount", account: **Your Account Number**},
{event: "setCustomerId", id: "<?php if(Mage::getSingleton('customer/session')->isLoggedIn()) {$customerData = Mage::getSingleton('customer/session')->getCustomer();echo $customerData->getId();
}?>"},
{event: "setSiteType", type: "d"},
{event: "trackTransaction" , id: "<?php echo $this->getOrderId(); ?>", item: [
<?php
$count = 0;
foreach ($items as $item):
$count++;
/* Get Configurable Sku from Simple product SKU/ID.
* If there is no configurable/simple product set up, then just use the standard Sku display
* */
$parentId = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($item->getProductId());
$configurableProductSku = Mage::getModel('catalog/product')->load($parentId)->getSku();
if ($configurableProductSku) {
$IdString .= $configurableProductSku;
}
else {
$idString .= $item->getSku();
}
$PriceString .= $item->getPrice();
$quantityString .= (int)$item->getQtyOrdered();
?>
<?php if( $count == count($items)): ?>
{ id: "<?php echo $IdString; ?>", price: <?php echo number_format($PriceString,2,'.',' ')?>, quantity: <?php echo $quantityString ?> }
<?php else: ?>
{ id: "<?php echo $IdString; ?>", price: <?php echo number_format($PriceString,2,'.',' ')?>, quantity: <?php echo $quantityString ?> },
<?php endif; ?>
<?php
$IdString = '';
$PriceString = '';
$quantityString ='';
endforeach;
?>
]}); </script>
----------------------------------
And That's All ...