0
votes

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.

  1. 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; }
  2. Then push the meta value in the dataLayer

    dataLayer.push({'transactionId': metaObj['WT.tx_i']});

  3. In GTM I created a macro GTM macro

  4. 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.

2

2 Answers

0
votes

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

0
votes

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});