Iam using Google Tag manager==GTM as well as 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. The VWO clicks and visits are counted correctly but not the conversion.
I have created a macro in GTM ({transactionTotal}) based on fetching the data.
First I get all the meta tags where we have the ecommerce values.
var metaObj = {}, m = document.getElementsByTagName('meta'), i = m.length; //scope expanded from only .head while (i--) { // looping down will result in the same behaviour as stopping @ 1st metaObj[m[i].name] = m[i].content; }Then push the meta value in the dataLayer
dataLayer.push({'transactionId': metaObj['WT.tx_i']});
In GTM I created a macro
in the confirmation page:
//should be the value of the order total var _vis_opt_revenue = ({transactionTotal});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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.