I am trying to add conversion tracking to my magento store. I know I need to add the following code and customize it so magento will share info with CA.
<script type="text/javascript">
var _caq = _caq || [];
var products = [];
products.push({Sku: 'ProductID', UnitPrice: 'item price here', Quantity: 'quantity here'});
products.push({Sku: 'ProductID', UnitPrice: 'item price here', Quantity: 'quantity here'});
_caq.push(["Order", {OrderId: 'OrderID', Revenue: 'oVal', CurrencyCode: '3 letter currency code here', Products: products}]);
so far i have been trying to get the data from the order with the following code:
<?php $orderId = $this->getOrderId();
$order = Mage::getModel('sales/order')->load($orderId);
$items = $order->getAllItems();
$_grand = $order->getGrandTotal();
$custname = $order->getCustomerName();
$itemcount=count($items);
foreach ($items as $itemId => $item)
{
$sObject2->Item_name__c = $item->getName();
$sObject2->Unit_price__c = $item->getPrice();
$sObject2->Sku__c = $item->getSku();
$sObject2->Quantity__c = $item->getQtyToInvoice();
}
echo $_grand;
echo $custname;
?>
When i try to echo the customers name and grand total, i get a blank for the total and Guest for the customer name. Even if i make the $orderId a number of an order this happens.