script for thank you page

General ShopSite user discussion

script for thank you page

Postby djhht » Wed Sep 03, 2014 8:32 am

I am trying to get this script to work for Visual Website Optimizer. I was told to add this on the Thank you page.

<script>
var _vis_opt_revenue=49;
</script>

... here 49 is a variable and changes depending on your cart system. You can read the article here-- http://visualwebsiteoptimizer.com/split-testing-blog/revenue-tracking-for-ab-testing/

I know the variable I need is ss_ordertotal, but I can't seem to get it to work on the Thank you page. I followed another post you had here in the forum and wrote this, but it is not working:

<script language="javascript">
<!--
/* Visual Website Optimizer Tracking */
var _vis_opt_revenue = ss_ordertotal;
//-->
</script>
djhht
 
Posts: 58
Joined: Thu Jul 15, 2010 9:24 am
Location: NC

Re: script for thank you page

Postby ShopSite Lauren » Wed Sep 03, 2014 9:12 am

That javascript is working for me.

I added that code to my "text that appears at the bottom of the thank you screen" field under Commerce Setup > Order System > Thank You, and added the line: document.write(_vis_opt_revenue); so that I would actually see (printed) the order total that is being collected in the javascript. You can try this yourself to see if it is working. Place the following code on your thank you screen, then place an order in your store. I have setup the code so that you should get an alert with the order total to verify that this code is working. I also changed the language to type since language is older code and not necessary, although either will work.


<script type="text/javascript">
var _vis_opt_revenue = ss_ordertotal;
alert(_vis_opt_revenue);
</script>

If the alert doesn't come up for you, I would first view the source of your thank you screen to make sure your javascript is there. If you have a custom template and you are using the "text on the bottom of the thank you screen field" then your custom template may not be using that field and the code may not be on your thank you screen at all.
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 889
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT

Re: script for thank you page

Postby djhht » Wed Sep 03, 2014 9:44 am

I am confused, you said
"I added the line: document.write(_vis_opt_revenue);"

but that line does not appear here:
<script type="text/javascript">
var _vis_opt_revenue = ss_ordertotal;
alert(_vis_opt_revenue);
</script>

am I supposed to add only this script?? and does the alert stay in there
<script type="text/javascript">
var _vis_opt_revenue = ss_ordertotal;
alert(_vis_opt_revenue);
</script>
djhht
 
Posts: 58
Joined: Thu Jul 15, 2010 9:24 am
Location: NC

Re: script for thank you page

Postby ShopSite Lauren » Wed Sep 03, 2014 9:52 am

I added the document.write to mine, and it printed on the page. I changed it to alert for the code I gave you because the alert is more obvious. If you add that code to your thank you page then place an order you can easily see if the code is working, because you will either see an alert or you wont. I'm not sure how you can tell that the code is working, but my guess is that you weren't getting reports or a notice in your visual web optimizer. I think that the code is working, and that there is some other issue. In order to see if this is the case, you will want to troubleshoot where the issue is. The code I gave you allows you to see if this part of the code is working or not, and if it is working (if you get the alert), then it is something else that isn't working or connected. If the alert does show up, then you can delete the alert line because it isn't needed, it's just to troubleshoot.
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 889
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT

Re: script for thank you page

Postby djhht » Wed Sep 03, 2014 11:52 am

It worked with the alert, but why does it not return the amount in the source code.

When I complete an order and 'view source' the code on the Thank you page, I see this

<script type="text/javascript">
var _vis_opt_revenue = ss_ordertotal;
</script>

When I view the Google code, it is showing all the field amounts. Why is my code not showing the amount, but instead the code. My testing guys wants the amount to be calculated server side like the Google code does.

google looks like this in source code
<script type="text/javascript">
_gaq.push(['_addTrans', "54618","","6.39","0.14","4.
djhht
 
Posts: 58
Joined: Thu Jul 15, 2010 9:24 am
Location: NC

Re: script for thank you page

Postby ShopSite Lauren » Wed Sep 03, 2014 1:11 pm

ss_ordertotal isn't a tag, so it doesn't get replaced with the value. Instead it is a variable (var). The alert working means that the code is working correctly. If you want to find the variable in the source code, you can do a ctrl+F and find "ss_ordertotal" and you will see it near the top of the page as var ss_ordertotal = "xx.xx".

In JavaScript, when a value is surrounded by quotes, it means that is the actual value. If a value is not surrounded by quotes, such as just plain ss_ordertotal, that means that the javascript will get the value FROM the var. The Google code you showed is giving the exact value. The ss_ordertotal is the var that the value will be pulled from. Both do the same thing, they just look different when you view the source code.

I'm not sure how else I can help you. The code that you provided originally is working correctly.
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 889
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT

Re: script for thank you page

Postby djhht » Wed Sep 03, 2014 1:28 pm

ok. thank you.
djhht
 
Posts: 58
Joined: Thu Jul 15, 2010 9:24 am
Location: NC


Return to User Forum

Who is online

Users browsing this forum: No registered users and 131 guests