Ecommerce tracking issue with FF/IE


#1

Hi,

I have a strange issue with piwik and hope maybe someone here can help me. I have installed piwik with magento and the traffic tracking is working, for the ecommerce tracking I have a strange issue: It is working with chrome, but not working with FF/IE/Safari (so basically it is working with chrome only). When I check the source code on the checkout confirmation page, it is the same on all browsers, but the script is somehow not called on FF/IE/Safari…Any hint how to track it down?

Thank You for any hint!
John


(Matthieu Aubry) #2

What script do you use for magento piwik tracking?


#3

Hi Matt,

first I had an ssl issue, this is fixed now. The code is working now in Safari/FF and Chrome, just IE still shows the error message from the try loop…I am using the following script on the sucess page: I have no idea, why IE is not accepting it, do you have any hint?

Thanks!
John


<!-- TRACKING FOR PIWIK START -->
	<?php // GET ORDER DATA FOR PIWIK>
	$piwik_order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
    	$p_amount = $piwik_order->getData('subtotal');
    	$p_total  = number_format($p_amount, 2, '.','');
    	$p_orderID = $loy_order->getIncrementId();
	?>


<script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);

<?php
foreach ($piwik_order->getAllVisibleItems() as $item) {

$p_productprice = number_format($item->getPrice(), 2, '.','');
$p_productqtyor = number_format($item->getQtyOrdered(), 0, '.','');
$p_productSKU   = $item->getSku();
$p_productName  = $item->getName();

echo 'piwikTracker.addEcommerceItem("' . $p_productSKU . '","' . $p_productName . '","socks_overknees",' . $p_productprice . ',' . 

$p_productqtyor . ');';
}
?>

piwikTracker.trackEcommerceOrder("<?php echo $p_orderID; ?>",<?php echo $p_total; ?>);
} catch( err ) { txt="there is an issue with the piwik script";alert(txt); }
</script>

<!-- TRAKCING FOR PIWIK END -->


#4

Hi Matt,

found it, fixed it! Here is the working code: there was just one linebreak and the > behind the php comment! Now it’s working, Piwik is GOLD! Love it!

Cheers
Markus


<!-- TRACKING FOR PIWIK START -->
        <?php
        // GET ORDER DATA FOR PIWIK
        $piwik_order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
        $p_amount = $piwik_order->getData('subtotal');
        $p_total  = number_format($p_amount, 2, '.','');
        $p_orderID = $loy_order->getIncrementId();
        ?>


<script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);

<?php
foreach ($piwik_order->getAllVisibleItems() as $item) {

$p_productprice = number_format($item->getPrice(), 2, '.','');
$p_productqtyor = number_format($item->getQtyOrdered(), 0, '.','');
$p_productSKU   = $item->getSku();
$p_productName  = $item->getName();

echo 'piwikTracker.addEcommerceItem("' . $p_productSKU . '","' . $p_productName . '","socks_overknees",' . $p_productprice . ',' .$p_productqtyor . ');';
}
?>

piwikTracker.trackEcommerceOrder("<?php echo $p_orderID; ?>",<?php echo $p_total; ?>);
} catch( err ) { txt="there is an issue with the piwik script";alert(txt); }
</script>

<!-- TRAKCING FOR PIWIK END -->



#5

one more fix…


<!-- TRACKING FOR PIWIK START -->
        <?php
        // GET ORDER DATA FOR PIWIK
        $piwik_order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
        $p_amount = $piwik_order->getData('subtotal');
        $p_total  = number_format($p_amount, 2, '.','');
        $p_orderID = $loy_order->getIncrementId();
        ?>


<script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);

<?php
foreach ($piwik_order->getAllVisibleItems() as $item) {

$p_productprice = number_format($item->getPrice(), 2, '.','');
$p_productqtyor = number_format($item->getQtyOrdered(), 0, '.','');
$p_productSKU   = $item->getSku();
$p_productName  = $item->getName();

echo 'piwikTracker.addEcommerceItem("' . $p_productSKU . '","' . $p_productName . '","socks_overknees",' . $p_productprice . ',' .$p_productqtyor . ');';
}
?>

piwikTracker.trackEcommerceOrder("<?php echo $p_orderID; ?>",<?php echo $p_total; ?>;
} catch( err ) { txt="there is an issue with the piwik script";alert(txt); }
</script>

<!-- TRAKCING FOR PIWIK END -->



#6

ok. last fix…


<!-- TRACKING FOR PIWIK START -->
        <?php
        // GET ORDER DATA FOR PIWIK
        $piwik_order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
        $p_amount = $piwik_order->getData('subtotal');
        $p_total  = number_format($p_amount, 2, '.','');
        $p_orderID = $piwik_order->getIncrementId();
        ?>


<script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);

<?php
foreach ($piwik_order->getAllVisibleItems() as $item) {

$p_productprice = number_format($item->getPrice(), 2, '.','');
$p_productqtyor = number_format($item->getQtyOrdered(), 0, '.','');
$p_productSKU   = $item->getSku();
$p_productName  = $item->getName();

echo 'piwikTracker.addEcommerceItem("' . $p_productSKU . '","' . $p_productName . '","socks_overknees",' . $p_productprice . ',' .$p_productqtyor . ');';
}
?>

piwikTracker.trackEcommerceOrder("<?php echo $p_orderID; ?>",<?php echo $p_total; ?>;
} catch( err ) { txt="there is an issue with the piwik script";alert(txt); }
</script>

<!-- TRAKCING FOR PIWIK END -->


(Matthieu Aubry) #7

Do you know a good Magento developer? We would like to sponsor the development of a magento plugin for Piwik tracking based off the older version of GPL plugin Jirafe which had most of the piwik code already done. Let me know if you know someone who would be interested and who is reliable? Thanks!