Jump to content

Měření Konverze - Heureka


krajic

Recommended Posts

Nazdar,

ja som použil takéto riešenie:

Moduly - Ganalytics - ganalytics.php

som funkciu hookOrderConfirmation upravil nasledovne

 

function hookOrderConfirmation($params)

{

if(Tools::getRemoteAddr() == Configuration::get('PS_MAINTENANCE_IP')) return '';

 

/* Setting parameters */

$parameters = Configuration::getMultiple(array('PS_LANG_DEFAULT'));

 

$order = $params['objOrder'];

if (Validate::isLoadedObject($order))

{

$deliveryAddress = new Address(intval($order->id_address_delivery));

 

$conversion_rate = 1;

if ($order->id_currency != Configuration::get('PS_CURRENCY_DEFAULT'))

{

$currency = new Currency(intval($order->id_currency));

$conversion_rate = floatval($currency->conversion_rate);

}

 

/* Order general information */

$output = '

<script type="text/javascript">

var gaJsHost = (("https:" == document.location.protocol ) ? "https://ssl." : "http://www.");

document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));

</script>

<script type="text/javascript">

try {

var pageTracker = _gat._createTracker("'.Configuration::get('GANALYTICS_ID').'");

pageTracker._trackPageview();

';

/* Heureka general information */

$heur = '<script type="text/javascript">

var _hrq = _hrq || [];

_hrq.push(["setKey", "__Semdajvlastnykluc__"]);';

 

 

/* Order information */

$output .= '

pageTracker._addTrans(

"'.intval($order->id).'", // Order ID

"PrestaShop", // Affiliation

"'.Tools::ps_round(floatval($order->total_paid) / floatval($conversion_rate), 2).'", // Total

"0", // Tax

"'.Tools::ps_round(floatval($order->total_shipping) / floatval($conversion_rate), 2).'", // Shipping

"'.addslashes($deliveryAddress->city).'", // City

"", // State

"'.addslashes($deliveryAddress->country).'" // Country

);

';

/* Heureka Order information */

$heur .= '

_hrq.push(["setOrderId", "'.intval($order->id).'"]);';

/* Product information */

$products = $order->getProducts();

foreach ($products AS $product)

{

$category = Db::getInstance()->getRow('

SELECT name FROM `'._DB_PREFIX_.'category_lang` , '._DB_PREFIX_.'product

WHERE `id_product` = '.intval($product['product_id']).' AND `id_category_default` = `id_category`

AND `id_lang` = '.intval($parameters['PS_LANG_DEFAULT']));

$output .= '

pageTracker._addItem(

"'.intval($order->id).'", // Order ID

"'.addslashes($product['product_reference']).'", // SKU

"'.addslashes($product['product_name']).'", // Product Name

"'.addslashes($category['name']).'", // Category

"'.Tools::ps_round(floatval($product['product_price_wt']) / floatval($conversion_rate), 2).'", // Price

"'.addslashes(intval($product['product_quantity'])).'" // Quantity

);

';

$heur .= '

_hrq.push(["addProduct", "'.addslashes($product['product_name']).'", "'.Tools::ps_round(floatval($product['product_price_wt']) / floatval($conversion_rate), 2).'", "'.addslashes(intval($product['product_quantity'])).'"]);

';

}

 

/* Send command information */

$output .= '

pageTracker._trackTrans();

 

} catch(err) {}

</script>';

/* Send command information */

$heur .= '

_hrq.push(["trackOrder"]);

 

(function() {

var ho = document.createElement("script"); ho.type = "text/javascript"; ho.async = true;

ho.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".heureka.sk/direct/js/cache/2-roi-async.js";

var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ho, s);

})();

</script>';

$output=$output.'

'.$heur;

 

return $output;

}

}

mne to funguje na 1.3.6.0 veľmi dobre

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...