如何在prestashop中将电子商务数据发送到数据层

如何在prestashop中将电子商务数据发送到数据层,prestashop,e-commerce,google-tag-manager,Prestashop,E Commerce,Google Tag Manager,我不是一个开发人员,但试图将电子商务数据发送到数据层。我看不到控制台中数据层的任何电子商务数据。我正在将数据添加到prestashop中的order-confirmation.tpl。下面是我如何发送数据的 <Script type = "text / javascript"> dataLayer = ( { 'transactionId' : '{literal} {$order_id} {/literal}' , 'transactionTotal' : {li

我不是一个开发人员,但试图将电子商务数据发送到数据层。我看不到控制台中数据层的任何电子商务数据。我正在将数据添加到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 }

数据层=({
“transactionId”:“{literal}{$order_id}{/literal}”,
'transactionTotal':{literal}{$total}{/literal},
'transactionTax':{literal}{$tax}{/literal},
'transactionShipping':{literal}{$expenses\u envoice}{/literal
} , 
'transactionProducts':[{/literal}{foreach from=$products
项目=产品名称=产品}{/literal}
{
“Sku”:“{literal}{$producto.id_product}{/literal}”,
'Name':'{literal}{$producto.Name}{/literal}',
价格:{literal}{$product.Price{/literal},
'数量':{literal}{$product.Quantity}{/literal}
}{Literal}{if$smarty.foreach.productos.iteration!=$Products
|@count}{literal},{/literal}{/if}{/literal}
{Literal}{/foreach}],{/Literal}
“事件”:“transactionComplete”
} )
{/Literal}

有普雷斯塔肖经验的人请帮忙。我使用谷歌标签管理器进行电子商务跟踪。谢谢,我也有同样的问题。您还必须编辑文件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*/

原始来源:

没有使用presta的经验,但始终使用dataLayer.push({…}),而不是使用“=”覆盖dataLayer。您的代码有太多问题。我认为在任何人都能帮助你之前,你需要格式化你的代码。