Adding tracking code to the Order Completion page

Where to place the code

In many cases, such as when integrating with Internet advertising systems like Google AdWords or an external affiliate tracking program, you might need to add tracking code to the “Order Completion” page in your storefront.

ProductCart version 3.5 and above

A new page has been created that is dedicated to hosting tracking code. The page is called orderCompleteTracking.asp and is located in the pc folder. Open the page in Notepad or your favorite HTML editor. You will see the following code.

<%

pOrderNumber = (int(pOID)+scpre)

'// HOW TO USE THIS PAGE
'// 1.) This file can help you add custom tracking code
'// 2.) The file is included at the bottom of orderComplete.asp, home.asp, and viewPrd.asp.
'// 3.) There are two sections in this page "TRACKING" and "LANDING": see below

	IF pcv_intOrderComplete=1 THEN	
	
		'////////////////////////////////////////////////////////////////////////////////////////
		'// TRACKING: enter below any code to TRACK the successful completion of an order
		'////////////////////////////////////////////////////////////////////////////////////////

		' Advanced users: you can use any of the following variables in your tracking code:
		' pOID:  This variable holds the order number from the ProductCart database
		' pOrderNumber: The order number shown to customer
		' ptotal: The order total amount
		' pOrderStatus: An integer representing the status of the order
		
		' ENTER your tracking code BELOW the ASP tag located on the next line.
		%>
		
		<%

	ELSE

		'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		'// LANDING: enter below any code to track a customer's LANDING on the hone page
		'// or product details page
		'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

		' ENTER your tracking code BELOW the ASP tag located on the next line.
		%>	
		
		<%

	END IF
%>

As you can see, the page is divided into two sections, one for hosting tracking code to be used when you are tracking the completion of an order, and another for hosting code that tracks a customer's visit to your store.

The page is heavily commented. Follow the comments on the page. All tracking code must be placed between the ASP tags.

%>
 Your tracking code goes here, between the closing and opening ASP code tags.
<%

See below for more information about how to use order-related variables in your tracking code (e.g. to “pass” the order total to the tracking system).

ProductCart version 3.12 and below

The page that hosts tracking information is called “orderComplete.asp” and it is located in the “pc” folder.

You will typically place your tracking code at the bottom of the page, right before the following line of code:

<!--#include file="footer.asp"-->

Order-related variables

Many tracking scripts will allow you to pass order-related variables to the third-party system that you are integrating your store with. Here are some of the variables that you can use.

  • Order ID = pIdOrder
  • Order total = ptotal
  • Customer ID = pidCustomer

In ASP, to write a variable to the page (and therefore also add it to your custom script), you will use the following code (e.g. for the order ID):

<%=pIdOrder%>

Example: Google AdWords

For example, the standard Google AdWords tracking code would look as follows (this is sample code taken directly from Google's documentation as of April 2008):

<!-- Google Code for Purchase Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = 1234567890;
var google_conversion_language = "en_US";
var google_conversion_format = "1";
var google_conversion_color = "666666";
if (<%=pTotal%>) {
var google_conversion_value = <%=pTotal%>;
}
var google_conversion_label = "Purchase";
//-->
</script>
<script language="JavaScript"
src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height=1 width=1 border=0
src="http://www.googleadservices.com/pagead/conversion/1234567890/?value=<%=pTotal%>&label=Purchase&script=0">
</noscript>

Note that the “pTotal” variable is written to the script 3 times.


Personal Tools