Skip to content Skip to sidebar Skip to footer

Insert Url Parameters Into Javascript Code

I'm doing some conversion and revenue tracking using Virtual Website Optimizer. To track revenues, they instruct you to add a piece of Javascript code on the thank you page to dete

Solution 1:

Function taken from here

Add this

functiongetParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = newRegExp(regexS);
  var results = regex.exec(window.location.search);
  if(results == null)
    return"";
  elsereturndecodeURIComponent(results[1].replace(/\+/g, " "));
}

Then change

var _vis_opt_revenue = 0;

to

var _vis_opt_revenue = getParameterByName("total");

Solution 2:

Try this

var _vis_opt_revenue = 
         '$' + window.location.pathname.split('?')[1].split('=')[1];

Post a Comment for "Insert Url Parameters Into Javascript Code"