Please help with Javacript

General ShopSite user discussion

Please help with Javacript

Postby vwdforums » Thu Dec 24, 2009 10:54 am

Hello,

A third party company sent us a piece of javacode to track their referrral orders. They said we only need to add the code on the confirmation page of the shopping cart along with the shopping cart total at the bottom of the page. We added in the [---SC cart ---]and [---SC totals---] but other than that have not modified the script. They are still not seeing test orders in their tracking database. We've also tried the code on the thank you page as well but it's still not showing up for them. Lastly we tried putting the code before the </head> section as well on both confirmation and thank you pages. Still nothing. Is this a correct way to pass a variable of the SC total to someone? I really need to get this going today or Saturday at the latest. Thanks for your help!

Here's the script in the cart.


<script type="text/javascript">

Sample CompanyPurchase = {
merchant_id: 'fc29e6c0-aa15-012c-',

// Set this to false once you're done testing
sandbox: false,

// This is where you put information about which items were purchased
items: [
{
name: "[-- SC_Cart --]",
total:"[-- SC_Totals --]"
]
}

// This loads the javascript. You won't need to alter this
var _tt = document.createElement('script');
_tt.setAttribute('type', 'text/javascript');
_tt.setAttribute('src', (document.location.protocol == "https:" ? "https:" : "http:") + '//tracking.samplecompany.com/javascripts/vendor.js');
document.getElementsByTagName("head")[0].appendChild(_tt);

</script>
VWD
vwdforums
 
Posts: 44
Joined: Fri Jun 13, 2008 7:37 pm

Postby Jim » Thu Dec 24, 2009 11:58 am

You will need to use the shopping cart javascript variables not the template tags to access that information. See http://www.shopsite.com/help/10.1/en-US ... ables.html

There are links on that page to how to setup google tag that you could use for an example of how to access the variables.
http://www.shopsite.com/help/10.1/en-US ... ytics.html
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Postby vwdforums » Thu Dec 24, 2009 2:19 pm

Jim, thank you so much for answering me. Especially given the fact that it's Christmas Eve. Your help is much appreciated. I'm trying the new code now. Thanks Again!
VWD
vwdforums
 
Posts: 44
Joined: Fri Jun 13, 2008 7:37 pm

Postby vwdforums » Tue Dec 29, 2009 2:36 am

Here's an update. I tried reading the links you sent me and I swapped out my variables. Now my code looks like this.

<script type="text/javascript">

companyPurchase = {
merchant_id: 'fc29e6c0-aa15-012c-f1d8',

// Set this to false once you're done testing
sandbox: false,

// This is where you put information about which items were purchased
items: [
{
name: "ss_name",
total:"ss_ordertotal"
]
}

// This loads the company javascript. You won't need to alter this
var _tt = document.createElement('script');
_tt.setAttribute('type', 'text/javascript');
_tt.setAttribute('src', (document.location.protocol == "https:" ? "https:" : "http:") + '//tracking.company.com/javascripts/vendor.js');
document.getElementsByTagName("head")[0].appendChild(_tt);

</script>

I've tried putting it above the </head> tag. I've also tried placing it within the [-- SC_JAVASCRIPT extras --] tag. Both located on the Confirmation page of the shopping cart template. It's still not passing the info to the third party company. Any ideas would be much appreciated.

Thanks!
VWD
vwdforums
 
Posts: 44
Joined: Fri Jun 13, 2008 7:37 pm

Postby Jim » Tue Dec 29, 2009 8:07 am

What level of ShopSite do you have, Pro, Manager or Starter?

Note that what they are calling the "Confirmation" page is probably what ShopSite is calling the Thank You page. The Confirmation page in ShopSite just displays the order and billing information and would not send the javascript variables to the tracking company.

So make sure you are putting this on the Thank you page and not the Confirmation page in ShopSite.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Postby vwdforums » Tue Dec 29, 2009 10:53 am

Thanks for getting back to me. We're running Shopsite 10. You know at one point I was thinking the same thing and I tried it on the Thank You page, but I think I still had the old Shopsite tags in there instead of the correct Java tags. I'll try putting it on the Thank you page with the java tags this time and test it again.
VWD
vwdforums
 
Posts: 44
Joined: Fri Jun 13, 2008 7:37 pm

Postby vwdforums » Wed Dec 30, 2009 8:30 pm

Well here is the update. I tried placing the code on the Thank you page. That did not work either. So I ask the third party company and they said I don't have to use the items attribute but could use just the total. They sent a new snippet of code. I thought this would make it much easier. However, it still does not work. The company claims many other clients (using other shopping carts) have used this code successfully. They say it's an issue with Shopsite.

Here's what I have on the Thank you page. I just did a cut paste from the beginning of the Thank you page section in the shopping cart to the end of the javascript. Do I have it in the correct location on the page?


#######################
[-- DEFINE ThankYou --]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
# ShopSite "Classic" Thank You Page Template

<html>
<head>

<title>[-- STORE.SC_ThankYou Remove_Html --]</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<script type="text/javascript" language="JavaScript">
<!--
[-- SC_JAVASCRIPT extras --]
// -->
</script>



<script type="text/javascript">

companyPurchase = {
merchant_id: 'fc29e6c0-aa15-012c-f1d8',
total: ss_ordertotal
}

// This loads the company javascript. You won't need to alter this
var _tt = document.createElement('script');
_tt.setAttribute('type', 'text/javascript');
_tt.setAttribute('src', (document.location.protocol == "https:" ? "https:" : "http:") + '//tracking.company.com/javascripts/vendor.js');
document.getElementsByTagName("head")[0].appendChild(_tt);

</script>



I also tried putting the "ss_ordertotal" in quotes but that did not work either. The third party company has no idea why this is not working. So any additional help you can give me would be much appreciated.

Thanks!
VWD
vwdforums
 
Posts: 44
Joined: Fri Jun 13, 2008 7:37 pm

Postby loren_d_c » Thu Dec 31, 2009 12:35 pm

Try replacing ss_ordertotal with just a number (like '1.00' or something) to take the ShopSite variable out of it, then place a test order and view the source of the thank you screen.

If your JavaScript shows up in the HTML source of the thank you screen yet it still isn't tracked by your tracking company, then there is some other problem, like perhaps the script has to be placed in the <body> of the page, not the <head>, or you have JavaScript off in your browser, or you have a browser add-on that blocks this kind of script, or you have to go through one of the tracking company's links first before you can be tracked, or their script is wrong, etc etc.

-Loren
loren_d_c
 
Posts: 2572
Joined: Fri Aug 04, 2006 12:02 pm
Location: Anywhere


Return to User Forum

Who is online

Users browsing this forum: No registered users and 150 guests