i have a Tracking script and i can't really fill out every detail as it needed.

This is how far i get, but i can't really programm PHP or know the full Magento Documentation to find what i need.

$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
$items = $order->getAllItems();
$currency = Mage::app()->getStore()->getCurrentCurrencyCode();?>

<script language="JavaScript">
var pg_pangora_merchant_id='MERCHANT_ID';
var pg_order_id='<?php echo $this->getOrderId(); ?>;
var pg_cart_size='<?php echo count($items); ?>';
var pg_cart_value='$cart_value';
var pg_currency='<?php echo $currency; ?>';
var pg_customer_flag='$customer_flag';
var pg_product_id='$product_id';
var pg_product_name='$product_name';
var pg_product_price='$product_price';
var pg_product_units='$product_units';</script>

<script language="JavaScript" src="https://clicks.pangora.com/sales-tracking/salesTracker.js"></script>

<noscript><img src="https://clicks.pangora.com/sales-tracking/MERCHANT_ID/salesPixel.do"/></noscript>

Here a description of the Vales and it's meaning:

  • pg_pangora: merchant_id is mine id at the provider(i can fill that out ;) )
  • pg_order_id: the OrderId, i think i will fill that out with that script.
  • pg_cart_size: The amount of all bought Articles.
  • pg_cart_value: The end Price without Taxes. A decimal separator must be a point.
  • pg_currency: Is the ISO 4217 Value of the currency. In my case it will be EUR.
  • pg_customer_flag: new or old for a new Customer or a Customer which already bought something bevor.
  • pg_product_id:The Single Product ID or a comma separated list of the ID's of the bought Products. Example: '2342,4534,432'
  • pg_product_name: A Single Product name or a comma separated list of the names of the Products. Example: 'product1,product2,product4'
  • pg_product_price: A Single product price a comma separated list of the prices of the products. Example '9.99,24.90,17.80'
  • pg_product_units: The amount of every product in the Order separated with comma. Example '3,1,1'

It would be very nice if someone could help me out.

  • 2
    This question appears to be off-topic because it is about pangora tracking and not magento – Fabian Blechschmidt Jul 16 '14 at 12:03
  • Yes, like this. – Fabian Blechschmidt Jul 16 '14 at 13:40
  • Magento covers operating an e-commerce website and one of the issues that always rears its ugly head is installing roi tracking. Installing custom image sliders aren't about Magento either, but they get answered as well. Or to put it another way, this may be about Pangora, but I can use the code submitted to work with, for example Hubspot, et al. – Fiasco Labs Jul 16 '14 at 14:45
  • OP does not know PHP, but this is a pre-requisite for accomplishing the task – benmarks Jul 18 '14 at 1:47

Try this:

$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
$items = $order->getAllVisibleItems(); //do not use getAllItems...you get bad results if you have configurable products
$merchantId = ...;//pangora should provide this. I suggest not hard coding it, maybe read it from config...your call
$orderId = $order->getIncrementId();
$currency = $order->getOrderCurrencyCode();
$subtotal = $order->getSubtotal();
$itemsCount = count($items);
$productIds = array();
$productNames = array();
$productPrices = array();
$productQtys = array();
foreach ($items as $item) {
    $productIds[] = $item->getProductId(); //I would advice in using $item->getSku();
    $productNames[] = str_replace(',', ' ', $item->getName());
    $productPrices[] = number_format($item->getPrice(), 2);
    $productQtys[] = $item->getQtyOrdered();
$customerOrders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_email', $order->getCustomerEmail());
$customerFlag = ($customerOrders->getSize() >=2) ? 'old' : 'new';

after this, your tracking code should look like this:

<script language="JavaScript">
    var pg_pangora_merchant_id=<?php echo $merchantId?>;
    var pg_order_id='<?php echo $orderId?>';
    var pg_cart_size='<?php echo $itemsCount?>';
    var pg_cart_value='<?php echo $subtotal?>';
    var pg_currency='<?php echo $currency; ?>';
    var pg_customer_flag='<?php echo $customerFlag; ?>';
    var pg_product_id='<?php echo implode(',', $productIds); ?>';
    var pg_product_name='<?php echo Mage::helper('core')->jsQuoteEscape(implode(',', $productNames)); ?>';
    var pg_product_price='<?php echo implode(',', $productPrices); ?>';
    var pg_product_units='<?php echo implode(',', $productQtys); ?>';

<script language="JavaScript" src="https://clicks.pangora.com/sales-tracking/salesTracker.js"></script>

<noscript><img src="https://clicks.pangora.com/sales-tracking/<?php echo $merchantId?>/salesPixel.do"/></noscript>

I didn't test the code, so syntax errors may appear. Test before using.

  • I get a Error in the Console PHP Fatal error: Call to a member function getCheckoutMethod() on a non-object in "apppath"/app/design/frontend/base/default/template/checkout/success.phtml on line 34 but THANK YOU. its awesome – Serverfrog Jul 16 '14 at 13:07
  • @Serverfrog. hmmm...I read again what you need for customer flag. I will update the answer soon. – Marius Jul 16 '14 at 13:09
  • @Serverfrog. see my update. The new approach is to see if there are at least 2 orders (the current one and at least one other) associated to the same customer email. – Marius Jul 16 '14 at 13:11
  • whao awesome. towone parts: The Currency is empty?var pg_currency=''; and in our product names exist commas (,). That result as example to var pg_product_name='iPhone 4, 8 GB, weiss, Apple-Garantie bis 08/2014'; which would be wrong because it's only one product that is a iPhone 4 with 8GB in white(weiß) with a limited warrenty. But Thanks ;) – Serverfrog Jul 16 '14 at 13:29
  • @Serverfrog. I've made the changes for currenty and product names. For currency it should be getOrderCurrencyCode instead of getCurrencyCode and I removed the commas from the product names – Marius Jul 16 '14 at 13:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.