[英]Save a value from Google Tag manager DataLayer in a JavaScript variable
Iam using Google Tag manager==GTM as well as Visual Website Optimizer==VWO. Iam使用Google跟踪代码管理器== GTM以及Visual Website Optimizer == VWO。 All the script tags for both application are implemented accordingly.
两个应用程序的所有脚本标签均已相应实现。
In order to be able to track revenue we have to save the transactionTotal of an order into a variable that VWO uses to count the conversion rates on a specific test. 为了能够跟踪收入,我们必须将订单的transactionTotal保存到一个变量中,VWO使用该变量来计算特定测试的转换率。 The VWO clicks and visits are counted correctly but not the conversion.
正确计算了VWO的点击和访问次数,但未正确计算转化次数。
I have created a macro in GTM ({transactionTotal}) based on fetching the data. 我已经基于获取数据在GTM({transactionTotal})中创建了一个宏。
First I get all the meta tags where we have the ecommerce values. 首先,我获得了所有具有电子商务价值的元标记。
Then push the meta value in the dataLayer 然后将meta值推送到dataLayer中
dataLayer.push({'transactionId': metaObj['WT.tx_i']}); dataLayer.push({'transactionId':metaObj ['WT.tx_i']});;
In GTM I created a macro 在GTM中,我创建了一个宏
in the confirmation page: 在确认页面中:
This returns an error and no value is save in this variable. 这将返回错误,并且该变量中没有任何值。
Any ideas or help is much appreciated. 任何想法或帮助将不胜感激。
I figured out I had a syntax error user parenthesis instead of curly brackets 我发现我有一个语法错误的用户括号而不是大括号
so it should be 所以应该
var _vis_opt_revenue = {{transactionTotal}};
instead of 代替
var _vis_opt_revenue = ({transactionTotal});
Could you indent your code please ? 您可以缩进代码吗? It will be much easier.
这样会容易得多。
Secondly, you use a macro that is looking for transactionTotal and you push on dataLayer an object named transactionId Therefore, it could not work 其次,您使用一个正在查找transactionTotal的宏,然后将一个名为transactionId的对象推入dataLayer,因此,它无法正常工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.