Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting a cookie and redirecting

Status
Not open for further replies.

nsampson1

IS-IT--Management
Sep 8, 2000
26
0
0
GB
Hi

I'm co-writing a coldfusion app which serves and tracks banner ad activity. When a user clicks on one of our advertiser's banners, I need the app to set a cookie and redirect the user to the merchant's click through page.

I know that you can't set a cookie and use cflocation in the same template. I've tried various alternative solutions and all to no avail:

1) using CFINCLUDE - I can't use cfinclude because the url that the user is being redirected to is a third party therefore I must specify the whole url.

2) using http meta refresh - we will be serving several million banners per month and performance would suffer due to the refresh

3) using CFHEADER refresh - same problem as above

4) setting the cookie and redirecting using 2 seperate custom tags - I thought this would seperate the cfcookie from the cflocation but not so. The cookie does not set.

5) using javascript - doesn't seem to work and users can turn off javascript at the client end which may cause problems.

6) using CFHTTP to get the merchant's clickthrough page. This works but displays the coldfusion template in the title bar instead of the merchant's url so that's no good to us either


Does anyone know of any way to achieve what we want without suffering a degradation in performance? Maybe we could try passing the url as a variable to an asp script. Would this work? Would we need to serialise the variable using CFWDDX before passing it to the asp page?

Any assistance would be invaluable to us as we're now banging our heads off brick walls.

Thanks in advance


Neil
 
Hi,

Maybe its useful to set your cookie on the page that you're redirecting to and than using the cgi variable cgi.http_referer. E.G. on your location page:

<cfif cgi.http_referer contains &quot;clickpage.cfm&quot;>
<cfcookie name=&quot;blabla&quot; value=&quot;blabla&quot;>
<cfelse>
<cflocation url=&quot;clickpage.cfm&quot;>
</cfif>
 
thanks for the suggestion

the problem is that the location pages will all be on third party websites who are using our software to advertise. We can't supply code for these pages and even if we could, the third party may not be using coldfusion.

thanks anyway
 
Hey Neil,

Based on your requirements, I don's see an easy solution. If I understood why you needed to set cookies, I might be able to suggest a better solution. Since the cookies you set on your site won't be passed to the 3rd party sites, I'm assuming that you want to set cookies so you can track users on your site. If so, what type of data are you trying to track? There might be another way to get what you want without setting the cookies on the click-through.

Good luck,
GJ

 
Hi GunJack

Although the cookie will not pass to the third party's website, we supply our third parties with a piece of hard-coded html that they insert into their landing page (ie the page I'm trying to redirect to). This script kicks off a coldfusion script at our domain which checks for the cookie and adds/changes stats in our dbase.

Without going into too much detail, we definitely need cookies.

I was considering looking into server-side java to see if it could handle the redirect and be embedded into our CF pages. Do you have any knowledge of this?

thanks
 
Is there any reason why you wouldn't create your cookies on the page that displays the banner ads? I'm guessing that you set a specific cookie for each banner ad and you don't want unnecessary cookies in your database. If this is the case, I would suggest going ahead and setting them for all ads and then use one of two options:

1. On the script that gets kicked off from the landing page, have it delete out all of the cookies that were set on the page but not used. Since you know the banner they clicked, you also know the banners they didn't click.
2. Have a script run every few hours or later that looks for cookies that were created but never used.

Let me know if there are other issues that would prevent this type of solution from working.
GJ
 
GunJack

the banner ads appear on affiliates' websites (third parties who display banners that are tracked with our software). When a user clicks on a banner, on any of the affiliates' websites and for any merchant, our CF code checks for the existence of a cookie (ie has the user clicked on one of our program's banners before) and adds variables recording affiliateid (specific to affilaite's account), merchantID (the merchant is the party who's website the user sees when they click the banner) and start date. If no cookie exists, it sets one. If the user at any time within the expiry date reaches our bit of code on the merchant's website (eg when they have made a purchase) then another of our scripts is run to check for the cookie and add the sale to the stats for that perticular merchant and that particular affiliate, depending on the cookie.

There's no real succinct way of descibing the whole banner delivery/tracking process so I understand that it's difficult to reach a solution.

The big problem is the fact that a cookie must be set at our end when a user clicks on a banner on an affiliate's website. In the same process, the user must be transported to the merchant's website. The html code we supply to the merchants does not go in their landing page. It actually goes into a page when a transaction has taken place on their system. Sorry about that.

Thanks for being so helpful.

I'm going home now but I'll check this thread again in the morning.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top