本文介绍了将Google AdWords转化跟踪(javascript)代码添加到PrestaShop / Smarty页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在运行PrestaShop网站,希望将其与Google AdWords及转换跟踪功能集成。 PrestaShop代码在Smarty 3中。I'm running a PrestaShop site and want to integrate it with Google AdWords and with the Conversion Tracking feature. The PrestaShop code is in Smarty 3.现在我发现我可以将Google的JS代码放在tpl文件的末尾:order-confirmation.tpl。这是谷歌代码:Now I've found that I could put Google's JS code at the end of a tpl file: order-confirmation.tpl. Here's the google code:<script type="text/javascript">/* <![CDATA[ */var google_conversion_id = <my id>;var google_conversion_language = "en";var google_conversion_format = "3";var google_conversion_color = "ffffff";var google_conversion_label = "<my label>";var google_conversion_value = {$total};/* ]]> */</script><script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"></script><noscript><div style="display:inline;"><img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/<id>/?value=0&label=<label>&guid=ON&script=0"/></div></noscript>问题是提供JS变量 google_conversion_value 与总订单价值的内容。The problem is feeding the JS variable google_conversion_value with the content of the total order value.我正在使用Smarty 3,我试图在{literal}标签之间包含整个JS块,或者没有用空格围绕大括号,没有空格,任何东西似乎都有效。I'm using Smarty 3, and I've tried to include the whole JS block between {literal} tags, or without then just surrounding the braces with spaces, without spaces, anything seems to work.该部分中的转换值也是相同的,googleadservices链接中的参数,当前设置为0,但是希望$ total值也去那里。Also the same conversion value is in the section, a parameter in the link to googleadservices, and it is currently set to 0, but I want the $total value to go there too.推荐答案看起来我不得不打电话给 getOrderTotal $ cart 对象上的/ code>:It looks like I had to call getOrderTotal on the $cart object:var google_conversion_value = {$cart->getOrderTotal(false, Cart::BOTH_WITHOUT_SHIPPING)};第一个参数是,如果你想获得税收总额。 第二个参数是Cart.php中的常量:First parameter is if you want to get the total with taxes or not.Second parameter is a constant in Cart.php:const ONLY_PRODUCTS = 1;const ONLY_DISCOUNTS = 2;const BOTH = 3;const BOTH_WITHOUT_SHIPPING = 4;const ONLY_SHIPPING = 5;const ONLY_WRAPPING = 6;const ONLY_PRODUCTS_WITHOUT_SHIPPING = 7;const ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING = 8; 这篇关于将Google AdWords转化跟踪(javascript)代码添加到PrestaShop / Smarty页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-05 16:56