PDA

View Full Version : ASP based web bug


dominicall
11-16-2002, 07:53 PM
Ok - who can help me with this one

I've developed an email system for my site that sends multipart/alternate emails and want to track whether someone opens the HTML version using a web-bug.

I know this can be done with CGI using an embedded single pixel transparent gif file, but can it be done with ASP (using VBscript)??? And if so, how???

Thanks

Dominic :D

whammy
11-16-2002, 08:07 PM
<img src="webbug.asp?id=<% = id %>" width="1" height="1" />

Assuming "id" is the primary key or whatever you're using to keep track of who it is. Then of course you can have a simple related table that gets a distinct count (you want distinct count instead of or in addition to total count because if someone opens the email in the preview pane, it also counts!).

;)

dominicall
11-16-2002, 08:32 PM
Yeah - I tried that using the below...

The image tag in the email....<img src="http://www.thinkingaboutmoving.co.uk/siteadmin/emailfiles/emailtracker.asp?p=[OfficeID]&c=[CampID]" width="1" height="1" alt="" border="0">BTW, the [OfficeID] and [CampID] are replaced as the sub loops thru the recordset...

The emailtracker file...If Request.QueryString("c") <> "" Then

Dim OfficeID, campaignID

OfficeID = Request.QueryString("p")
campaignID = Request.QueryString("c")

Set cmdTrackEmail
cmdTrackEmail = Server.CreateObject("ADODB.Command")
cmdTrackEmail.ActiveConnection = strConnection
cmdTrackEmail.CommandText = "spTrackEmail"
cmdTrackEmail.CommandType = adCmdStoredProc

Dim objParam1 : Set objParam1 = cmdTrackEmail.CreateParameter ("@OfficeID",adInteger,adParamInput)
Dim objParam2 : Set objParam2 = cmdTrackEmail.CreateParameter ("@CampCode",adIngeger,adParamInput)

cmdTrackEmail.Parameters.Append objParam1
cmdTrackEmail.Parameters.Append objParam2

cmdTrackEmail.Parameters("@OfficeID") = OfficeID
cmdTrackEmail.Parameters("@CampCode") = campaignID

cmdTrackEmail.Execute

Set cmdTrackEmail = Nothing

End If

Response.Write "http://www.thinkingaboutmoving.co.uk/images/general/transparent.gif"

and the stored procedure...CREATE PROCEDURE spTrackEmail (
@OfficeID [int],
@CampCode [int]
)
AS
UPDATE tbl_CampHistory
SET HTMLopened = 1
WHERE OfficeID = @OfficeID AND CampCode = @CampCode
GO

But it doesn't update the campaign history table.

Any ideas???

Dominic :D

whammy
11-16-2002, 09:16 PM
Microsoft VBScript compilation error '800a03f3'

Expected '='

/siteadmin/emailfiles/emailtracker.asp, line 9

Set cmdTrackEmail
-----------------^

That should be:

Set cmdTrackEmail = Server.CreateObject("ADODB.Command")


;)

dominicall
11-16-2002, 09:42 PM
Oops - LOL

Dominic :o

dominicall
11-16-2002, 09:54 PM
Hmmmm... still doesn't work????

Any ideas???

******************************
Don't worry, figured it....

If I am going to use 'strConnection' and 'adCmdStoredProc' in my command then I really should include the connection and adovbs.inc files.... how embarasing


Dominic :o

whammy
11-16-2002, 11:34 PM
Heheh... don't worry sometimes the simplest things are what get you.

I hate when I wrote a really cool script, and then I realize it doesn't work because I left something obvious out.

:)