我不是开发人员,而是尝试将电子商务数据发送到数据层。我无法在控制台中看到任何电子商务数据到数据层。我将数据添加到prestashop中的order-confirmation.tpl。以下是我发送数据的方式
<Script type = "text / javascript">
dataLayer = ( {
'transactionId' : '{literal} {$order_id} {/literal}' ,
'transactionTotal' : {literal } { $total_a_payment } {/literal } ,
'transactionTax' : { literal } { $tax } { /literal } ,
'transactionShipping' : { literal } { $ expenses_envoice } { /literal
} ,
'transactionProducts' : [ { /literal } { foreach from = $ products
item = product name = products } { /literal }
{
'Sku' : '{literal}{$producto.id_product}{/literal}' ,
'Name' : '{literal}{$producto.name}{/literal}' ,
'Price' : { literal } { $ product . Price_wt } { /literal } ,
'Quantity' : { literal } { $ product . Quantity } { /literal }
} { Literal} {if $ smarty.foreach.productos.iteration! = $ Products
| @count} {literal}, {/ literal } { / if } { /literal }
{ Literal} {/ foreach } ] , { /literal }
'Event' : 'transactionComplete'
} )
</ Script>
{ / Literal }
任何人都有prestashop的经验请帮忙。我正在使用Google跟踪代码管理器进行电子商务跟踪。感谢
答案 0 :(得分:0)
我有同样的问题。您还必须编辑文件 controllers / front / OrderConfirmationController.php 。 找到函数displayOrderConfirmation并插入类似这部分代码:
$order = new Order($this->id_order);
$currency = new Currency($order->id_currency);
/* added part */
$cart = new Cart($order->id_cart);
$products = $cart->getProducts();
$this->context->smarty->assign(array(
'order_id'=> $this->id_order,
'total_a_payment'=> $order->total_paid_tax_incl,
'expenses_envoice'=> $order->total_shipping_tax_incl,
'tax'=> ($order->total_paid_tax_incl - $order->total_paid_tax_excl),
'products' => $products
));
/*end of added*/
原始来源:https://www.prestashop.com/forums/topic/618328-variables-for-google-tag-manager/