|
Sample Direct Marketing Campaign
This sample HTML code could be used to track recipients actions
when opening marketing email messages in a direct marketing campaign.
With most direct marketing campaigns a bulk email application is
used to send mail based on a template to an organisation's customer
base. When the bulk email application sends the mail it replaces
fields in the tempate (for instance email address, contact name,
company name etc.) with the actual details of the customer.
The following code (which is the body of the email message sent)
will generate a hit and associated log entry on the web server called
<myserver>, when a user (with email address joebloggs@somedomain.com)
opens the email, sent in HTML format, with an email client application
(for instance Microsoft Outlook Express, Netscape Mail etc.). The
log line generated, when processed by SurfStats, will be recognized
by the SurfStats eCommerce module as an eCommerce transaction of
type optin (from the value of the zztype query parameter).
The file emailopened.asp (name not specific) must exists on the
server, but need not contain any meaningful code.
...
<BODY>
...
...(your marketing info)
...
<IMG width=1 height=1 src="http://<myserver>/emailopened.asp?zztype=optin&id=Jun
2004 Promo&detail=joebloggs@somedomain.com&action=Email Opened">
</BODY>
...
This example also illustrate the use of the action parameter,
which you may want to use to capture other actions performed by
the recipient, for instance forwarding the email, opening a page
on your site by clicking a hyperlink embedded in the email etc.
If your bulk email software allows it you may also want to configure
it to call a URL after each email sent by the software allowing
you to track exactly which recipients the email got sent to, opened
it etc.
Sample Shopping Cart User Interaction
This sample ASP code could be used to track the interaction of a
user with a shopping cart on a site. The code shown here generates
a hit and associated log entry on the web server called <myserver>
for each product purchased after the user has selected the products,
filled in the shopping details and paid for the items in the cart.
It is assumed that this code executes on an IIS server in an Active
Server Page (ASP), using server-side VBScript. The ASP code executes
and generates the <IMG> tags in the HTML sent to the user's browser
which requests the URL specified in the src attribute - generating
the hit line on the server.
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
function body_onload()
{
// shopthanks.asp is this cart software's original order
// confirmation page. So the HTML code in this page will
// get executed (in the user's browser) to generate the
// eCommerce hit lines. Then the user will get redirected
// to shopthanks.asp.
location.href = './shopthanks.asp';
}
</SCRIPT>
</HEAD>
<BODY onload="body_onload()">
<%
' The following server-side VBScript code accesses the database
maintained by the
' shopping cart and reads each line item in the order one by one.
This code should
' be adapted for the specific cart you want to use, but the concept
should remain the
' same. A lot of shopping carts keeps an object on the server with
the order details
' while the user is interacting with the cart. Alternatively you
could query this object
' which may be faster.
' ordernumber and database connection (myconn) was set up in code
not shown.
Dim strSQLoi
Dim oItems
Dim ssitemname
Dim ssquantity
Dim ssunitprice
Dim sstotalprice
Dim ssprodcat
strSQLoi = "select oitems.catalogid, oitems.numitems, oitems.unitprice,
" & _
"products.catalogid, products.cname, products.ccategory, " & _
"categories.categoryid, categories.catdescription " & _
"FROM oitems, products, categories " & _
"WHERE oitems.orderid = " & ordernumber & _
" AND oitems.catalogid = products.catalogid AND products.ccategory = categories.categoryid"
Set oItems = myconn.Execute(strSQLoi)
If oItems.EOF Then
' no items found - do what you need to do
End If
Do While Not oItems.EOF
ssitemname = oItems("cname")
ssquantity=oItems("numitems")
ssunitprice=oItems("unitprice")
sstotalprice=ssquantity*ssunitprice
ssprodcat=oItems("catdescription")
GenerateSurfStatsLogEntry "order","Cart Complete", _
"","",ssitemname,ssprodcat,ordernumber,"","","",ssquantity,"",CStr(sstotalprice)
oItems.MoveNext
Loop
Set oItems = Nothing
End Sub
%>
</BODY>
</HTML>
The VBScript procedure (Sub) GenerateSurfStatsLogEntry that gets
called can reside in a separate file (for instance surfstatslogging.asp)
and be included (for instance with <!-- #include file="surfstatslogging.asp"
-->) in each ASP file that needs to call it and called at the point
where a log entry needs to be generated.
<%
..
Sub GenerateSurfStatsLogEntry( _
zztype,action,source,campaign,product,prodcat,orderid,affid,affperc,detail,quantity,cost,revenue)
Dim ssLogLine
Dim rVal
Dim dummy
' Change the value for loghostfile if you want the log entry to
be generated to a different server
' than the server with the site and cart, for instance http://196.1.1.1/logtransaction.asp
Dim loghostfile
loghostfile = "./logtransaction.asp"
If zztype="" Then
Exit Sub
End If
Randomize
dummy = Int((9999999) * Rnd) 'to prevent caching
ssLogLine = "<IMG width=1 height=1 src=" & chr(34) & loghostfile
& _
"?zztype=" & zztype & chr(38) & "action=" & action & chr(38)
& _
"source=" & source & chr(38) & _
"campaign=" & campaign & chr(38) & _
"product=" & product & chr(38) & _
"prodcat=" & prodcat & chr(38) & _
"orderid=" & orderid & chr(38) & _
"affid=" & affid & chr(38) & _
"affperc=" & affperc & chr(38) & _
"detail=" & detail & chr(38) & _
"quantity=" & quantity & chr(38) & _
"cost=" & cost & chr(38) & _
"revenue=" & revenue & chr(38) & _
"dummy=" & CStr(dummy) & chr(34) & "></IMG>" & vbCrLf
Response.Write ssLogLine
End Sub
..
%>
Again you can use the action parameter to indicate other types of
interactions between the user and the shopping cart. For instance
when the user views the cart, when items are added to the cart,
when shipping details are entered etc. Analysis of the number and
percentage of actions performed will help in determining for instance
why users abandon shopping carts and the reason for abandonement.
|