Tracking the Magento sales revenue generated from your Bing Advertising is something that lots of people want to do, but it’s not documented anywhere in the Bing Ads site.
The first step to tracking your Bing ads on Magento is to add the Bing UET Code to your site. They recommend that you add it in the head of every page of the site as the last item in the head. Bing UET Code is kind of like their equivalent to Google Analytics code. It allows for conversion tracking as well as setting up goals, which could be for things like add to cart, or proceed to checkout, as well as completing checkout.
<head> {Meta tags and stylesheets, other javascript, etc.} {Bing UET Code Goes here} </head>
There is a whole section on how to setup Universal Event Tracking (UET) on the Bing Help website:
http://help.bingads.microsoft.com/apex/index/3/en-us/n5012
In Magento, the file I used for adding the code to the head at the bottom of the file:
{your magento home}/app/design/frontend/{your package}/{your theme}/template/page/html/head.phtml
After you have successfully added the UET Code to every page on your site, the next thing to do is to setup a goal for completing a checkout.
In the bing ads control panel, you do this by going to Conversion Tracking in the left side bar, and then to Conversion Goals. Next Click Create Conversion Goal. The screenshots below should help you through this step.
This is the code that you add to your success.phtml file to get the revenue value transmitted to Bing. I recommend putting it at the very end of the file. If you don’t know where to find this file, go to:
{your magento home}/app/design/frontend/{your package}/{your theme}/template/checkout/success.phtml
If there is no success.phtml file in that location, copy the file from:
{your magento home}/app/design/frontend/base/default/template/checkout/success.phtml
to your theme’s corresponding location. You may have to create the checkout directory if your theme has no checkout modifications yet.
<script> <?php $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getSingleton('sales/order')->load($lastOrderId); ?> window.uetq = window.uetq || []; window.uetq.push({ 'gv': '<?php echo $order->getBaseGrandTotal(); ?>'}); // Pass the computed revenue </script>
Leave a Reply