0

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 determine the actual revenue earned.

<script type="text/javascript">
var _vis_opt_revenue = 0;
//zero should be replaced by the actual revenue figure
</script>

I'm using a Wufoo form and made it so that I can add a URL parameter that totals up their order, so for example if their order has a total of $280 they'll be sent to:

http://mysite.com/thank-you?total=280

I'm wondering: how can I make it so that URL parameter is inserted into the Javascript tracking code from Visual Website Optimizer?

Thanks in advance.

1

2 Answers 2

3

Function taken from here

Add this

function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.search);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

Then change

var _vis_opt_revenue = 0;

to

var _vis_opt_revenue = getParameterByName("total");
Sign up to request clarification or add additional context in comments.

4 Comments

Should should vote to close the question as duplicate if you can answer it with an existing answer. But I guess you know that...
@FelixKling hmm, I added content which the OP might not know (using the function).
Thanks, that helped. And yes, it was useful -- I didn't know how to use the function itself. Using document.write it displays the parameter, so this might work.
this does look right. But is it the only way the value is passed over to the page?
0

Try this

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.