ASP to PHP
Posted: Thu Jul 14, 2011 11:18 pm
Hi Guys,
I wonder if one of you gurus can help me.
I am trying to convert the following FORM processing code in to PHP:
<!-- Beginning of Google Tracking Script -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-########-#']);
_gaq.push(['_setDomainName', '.CustomerDomain.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setAllowHash', false]);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'<% = Request.Form("orderID")%>', // order ID - required
'Your Company Name Here', // affiliation or store name
'<% = Request.Form("Total")%>', // total - required
'<% = Request.Form("tax")%>', // tax
'<% = Request.Form("shippingAmount")%>', // shipping
'<% = Request.Form("shipCity")%>', // city
'<% = Request.Form("shipState")%>', // state or province
'<% = Request.Form("shipCountry")%>' // country
]);
// add item might be called for every item in the shopping cart
// where your ecommerce engine loops through each item in the cart and
// prints out _addItem for each
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku1")%>', // SKU/code - required
'<% = Request.Form("product1")%>', // product name
'<% = Request.Form("option1")%>', // category or variation
'<% = Request.Form("price1")%>', // unit price - required
'<% = Request.Form("quantity1")%>' // quantity - required
]);
<% IF Len(Request.Form("product2")) > 0 THEN %>
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku2")%>', // SKU/code - required
'<% = Request.Form("product2")%>', // product name
'<% = Request.Form("option2")%>', // category or variation
'<% = Request.Form("price2")%>', // unit price - required
'<% = Request.Form("quantity2")%>' // quantity - required
]);
<% END IF
IF Len(Request.Form("product3")) > 0 THEN %>
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku3")%>', // SKU/code - required
'<% = Request.Form("product3")%>', // product name
'<% = Request.Form("option3")%>', // category or variation
'<% = Request.Form("price3")%>', // unit price - required
'<% = Request.Form("quantity3")%>' // quantity - required
]);
<% END IF
IF Len(Request.Form("product4")) > 0 THEN %>
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku4")%>', // SKU/code - required
'<% = Request.Form("product4")%>', // product name
'<% = Request.Form("option4")%>', // category or variation
'<% = Request.Form("price4")%>', // unit price - required
'<% = Request.Form("quantity4")%>' // quantity - required
]);
<% END IF
IF Len(Request.Form("product5")) > 0 THEN %>
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku5")%>', // SKU/code - required
'<% = Request.Form("product5")%>', // product name
'<% = Request.Form("option5")%>', // category or variation
'<% = Request.Form("price5")%>', // unit price - required
'<% = Request.Form("quantity5")%>' // quantity - required
]);
<% END IF
IF Len(Request.Form("product6")) > 0 THEN %>
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku6")%>', // SKU/code - required
'<% = Request.Form("product6")%>', // product name
'<% = Request.Form("option6")%>', // category or variation
'<% = Request.Form("price6")%>', // unit price - required
'<% = Request.Form("quantity6")%>' // quantity - required
]);
<% END IF %>
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- End of Google Tracking Script -->
This script is basically for a thank you page for a 1 shopping cart product, I am trying to pull the transactional data from 1 Shopping Cart to Google analytics's to see revenue/transactional data.
This is the last response I got from the guy that wrote the script above-
The tracking code has ASP code to read the FORM posted transaction variables from 1SCart and place them in the applicable variables for Google.
I am not a .NET (aspx, I believe) programmer so you will either have to make the thank you page an ASP one or change the ASP code to match your programming language. Remember, because you need to process FORM posted variables, you will have to use a non-HTML language like ASP or PHP.
An example of the ASP code is:
'<% = Request.Form("orderID")%>', // order ID - required
'Company Name', // affiliation or store name
'<% = Request.Form("Total")%>', // total - required
'<% = Request.Form("tax")%>', // tax
'<% = Request.Form("shippingAmount")%>', // shipping
'<% = Request.Form("shipCity")%>', // city
'<% = Request.Form("shipState")%>', // state or province
'<% = Request.Form("shipCountry")%>' // country
You will need to take the ASP code between the two tick marks and replace it with applicable FORM processing code for ASPX or whatever language you are writing.
Note that if you have this code as a separate, included file that goes into a larger, ASPX file for example, an HTML extension is fine because whatever extension (e.g. ASPX) of the parent thank you file will cause the applicable code within the HTML file to be executed.
To test that my code works, if you can process ASP files, create a basic ThankYou.asp file with the tracking code right beneath the <head> tag. When 1SCart goes to this page, all of the proper variables will be processed and sent to Google. From there, you can convert it into ASPX.
-------------------------------------------
One of my friends suggested I come over to this forum and ask you guys because you are all super clever
Be great if you understand or could help me.
Thank you.
I wonder if one of you gurus can help me.
I am trying to convert the following FORM processing code in to PHP:
<!-- Beginning of Google Tracking Script -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-########-#']);
_gaq.push(['_setDomainName', '.CustomerDomain.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setAllowHash', false]);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'<% = Request.Form("orderID")%>', // order ID - required
'Your Company Name Here', // affiliation or store name
'<% = Request.Form("Total")%>', // total - required
'<% = Request.Form("tax")%>', // tax
'<% = Request.Form("shippingAmount")%>', // shipping
'<% = Request.Form("shipCity")%>', // city
'<% = Request.Form("shipState")%>', // state or province
'<% = Request.Form("shipCountry")%>' // country
]);
// add item might be called for every item in the shopping cart
// where your ecommerce engine loops through each item in the cart and
// prints out _addItem for each
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku1")%>', // SKU/code - required
'<% = Request.Form("product1")%>', // product name
'<% = Request.Form("option1")%>', // category or variation
'<% = Request.Form("price1")%>', // unit price - required
'<% = Request.Form("quantity1")%>' // quantity - required
]);
<% IF Len(Request.Form("product2")) > 0 THEN %>
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku2")%>', // SKU/code - required
'<% = Request.Form("product2")%>', // product name
'<% = Request.Form("option2")%>', // category or variation
'<% = Request.Form("price2")%>', // unit price - required
'<% = Request.Form("quantity2")%>' // quantity - required
]);
<% END IF
IF Len(Request.Form("product3")) > 0 THEN %>
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku3")%>', // SKU/code - required
'<% = Request.Form("product3")%>', // product name
'<% = Request.Form("option3")%>', // category or variation
'<% = Request.Form("price3")%>', // unit price - required
'<% = Request.Form("quantity3")%>' // quantity - required
]);
<% END IF
IF Len(Request.Form("product4")) > 0 THEN %>
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku4")%>', // SKU/code - required
'<% = Request.Form("product4")%>', // product name
'<% = Request.Form("option4")%>', // category or variation
'<% = Request.Form("price4")%>', // unit price - required
'<% = Request.Form("quantity4")%>' // quantity - required
]);
<% END IF
IF Len(Request.Form("product5")) > 0 THEN %>
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku5")%>', // SKU/code - required
'<% = Request.Form("product5")%>', // product name
'<% = Request.Form("option5")%>', // category or variation
'<% = Request.Form("price5")%>', // unit price - required
'<% = Request.Form("quantity5")%>' // quantity - required
]);
<% END IF
IF Len(Request.Form("product6")) > 0 THEN %>
_gaq.push(['_addItem',
'<% = Request.Form("orderID")%>', // order ID - required
'<% = Request.Form("sku6")%>', // SKU/code - required
'<% = Request.Form("product6")%>', // product name
'<% = Request.Form("option6")%>', // category or variation
'<% = Request.Form("price6")%>', // unit price - required
'<% = Request.Form("quantity6")%>' // quantity - required
]);
<% END IF %>
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- End of Google Tracking Script -->
This script is basically for a thank you page for a 1 shopping cart product, I am trying to pull the transactional data from 1 Shopping Cart to Google analytics's to see revenue/transactional data.
This is the last response I got from the guy that wrote the script above-
The tracking code has ASP code to read the FORM posted transaction variables from 1SCart and place them in the applicable variables for Google.
I am not a .NET (aspx, I believe) programmer so you will either have to make the thank you page an ASP one or change the ASP code to match your programming language. Remember, because you need to process FORM posted variables, you will have to use a non-HTML language like ASP or PHP.
An example of the ASP code is:
'<% = Request.Form("orderID")%>', // order ID - required
'Company Name', // affiliation or store name
'<% = Request.Form("Total")%>', // total - required
'<% = Request.Form("tax")%>', // tax
'<% = Request.Form("shippingAmount")%>', // shipping
'<% = Request.Form("shipCity")%>', // city
'<% = Request.Form("shipState")%>', // state or province
'<% = Request.Form("shipCountry")%>' // country
You will need to take the ASP code between the two tick marks and replace it with applicable FORM processing code for ASPX or whatever language you are writing.
Note that if you have this code as a separate, included file that goes into a larger, ASPX file for example, an HTML extension is fine because whatever extension (e.g. ASPX) of the parent thank you file will cause the applicable code within the HTML file to be executed.
To test that my code works, if you can process ASP files, create a basic ThankYou.asp file with the tracking code right beneath the <head> tag. When 1SCart goes to this page, all of the proper variables will be processed and sent to Google. From there, you can convert it into ASPX.
-------------------------------------------
One of my friends suggested I come over to this forum and ask you guys because you are all super clever
Be great if you understand or could help me.
Thank you.