homepage Welcome to WebmasterWorld Guest from 54.161.192.130
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
1 pixel web bug on thank you page, reading cookies?
nonstop

10+ Year Member



 
Msg#: 3100152 posted 8:53 am on Sep 28, 2006 (gmt 0)

Hi,

Im trying to read a cookie set by another domain from a site's thank you page, however i have found that i cannot read a cookie set by another domain.

for example.

user visits site A (cookie set)
user is directed to site B
user ends up at a certian page on site B (cookie A read and value passed back to site A)
site A updates database

I have seen some sites loading a 1 pixel image (google seem to do this with their conversion tracker)

but when i try to do something like:

<img height="1" Width="1" src="http://www.mydomain.com/tracker.php">

and my tracker.php script tries to read a cookie that was set on mydomain.com, it can't.

i also tried

<iframe src="http://www.mydomain.com/tracker.php">

but that doesnt work either :(

so how do google and other affiliate programs/networks do it?

 

barns101

5+ Year Member



 
Msg#: 3100152 posted 9:37 am on Sep 28, 2006 (gmt 0)

As far as I am aware, one domain cannot read the cookies set by another domain because of the privacy and security issues.

nonstop

10+ Year Member



 
Msg#: 3100152 posted 10:04 am on Sep 28, 2006 (gmt 0)

yep that's what I thought, but then how do affiliate networks and google track conversions?

supermanjnk

10+ Year Member



 
Msg#: 3100152 posted 10:56 am on Sep 28, 2006 (gmt 0)

user visits site A (cookie set)

You could have GET values in the url here.

user is directed to site B

Here you can store the $_SERVER["HTTP_REFERER"] into a session variable

user ends up at a certian page on site B (cookie A read and value passed back to site A)

When the user gets to this page you can call up the session variable and use regular expression or some other method to pull out the values you need.

site A updates database

Update the database with the above values.

*added
You could also just have the information passed in the redirect and have the values attached to the redirect url. so you would have [sitea...]

which would then redirect to [siteb...]

from there store those into a session and call them when you get to that point, I would also check that the http_referer is from site a using this method so you don't have people typing in random values.

nonstop

10+ Year Member



 
Msg#: 3100152 posted 5:00 pm on Sep 28, 2006 (gmt 0)

hmm yea, but I need a soultion that will work over x number of days and sessions only last 20 minutes normally.

everywhere ive looked uses a cookie but i can't find anything on the net about how to do this :(

there must be someway to read a cookie back from another domain, from the sale confirmation/thank you page.

anyone?

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3100152 posted 6:05 pm on Sep 28, 2006 (gmt 0)

>> there must be someway to read a cookie back from another domain

there isn't

if you store the sessions in a db then you can have them expire whenever you like

supermanjnk

10+ Year Member



 
Msg#: 3100152 posted 6:19 pm on Sep 28, 2006 (gmt 0)

>> there must be someway to read a cookie back from another domain

If this were possible, security would go down the drain, Imagine someone reading cookies off of your computer from amazon.com, ebay.com etc then submiting that data to a database for their use later.

nonstop

10+ Year Member



 
Msg#: 3100152 posted 8:02 pm on Sep 28, 2006 (gmt 0)

then how do affiliate networks track sales conversions?

for example, an affiliate link might look like this:

[example-network.com...]

now at that point a cookie is written, lasting say 30 days, what's in the cookie I dont know. im guessing the affiliateID.

the user checks out domain.com and doesn't buy anything.

29 days later, the customer visits domain.com again and buys something. on the final chekout page after the sale there is a small web bug like this.

<img src="http://example-network.com/check" width="1" height="1">

and somehow unless im missing something, the sale is recorded on the affiliate network for that affiliateID, and the affiliate credited. with a percentage.

the same thing happens with Google AdWords. If you signup for an account your ad links look like this..

[google.com...] numbers and letters>&adurl=http://www.mydomain.com

a cookie written at this point.

but google offer a conversion tracking feature with some cleaver javascript on your thank you page..

How would google know that a user clicked on a certain keyword and ended up at the thank you page? or how does the affiliate network know that a user came back 29 days later to buy something?

[edited by: jatar_k at 9:58 pm (utc) on Sep. 28, 2006]
[edit reason] removed code dump [/edit]

supermanjnk

10+ Year Member



 
Msg#: 3100152 posted 10:46 pm on Sep 28, 2006 (gmt 0)

>>http://www.google.com/pagead/iclk?sa=l&ai=<random numbers and letters>&adurl=http://www.mydomain.com

A cookie is written at this point... On googles servers, not the place you are being redirected to or coming from. (this is also assuming that google uses cookies, they most likely don't they mostlikely store the information in a database.)

I don't see why you can't just pass the data you need to from site a with a link

siteb/mmmmcookie.php?id=whatever&whatever=whatever&url=siteb

then take that information once you get to the site, store it in a cookie then use a header redirect to go to the page they need to be on for site b...

nonstop

10+ Year Member



 
Msg#: 3100152 posted 11:29 pm on Sep 28, 2006 (gmt 0)

thanks but I'm not sure I understand your GET method. I can't install a php script on the target domain (siteb), i can only add something to the thankyou page.

this is what im trying to achive:


Commission Monster uses a cookie based method to track sales, leads and clicks through it's network. Cookies are the most popular form of affiliate tracking as they provide a great solution to the stateless nature of the http protocol. In short when an internet user clicks your link on an affiliate's website the user will be transported to our server briefly where a cookie is set in their browser before our server redirects them to your website.

You need to place our tracking pixel on your thank you page. This will be the page where the desired action has been completed like "your order number is #" or "thank you for completing our survey". If the internet user buys something from your website or completes a lead action when shown this page the <img> tag will execute a script that checks the internet users computer for our cookie. If the cookie indicates that the user was sent from an affiliate's website our system will credit the affiliate and debit your account for the respective amount due.


supermanjnk

10+ Year Member



 
Msg#: 3100152 posted 1:06 pm on Sep 29, 2006 (gmt 0)


Commission Monster uses a cookie based method to track sales, leads and clicks through it's network. Cookies are the most popular form of affiliate tracking as they provide a great solution to the stateless nature of the http protocol. In short when an internet user clicks your link on an affiliate's website the user will be transported to our server briefly where a cookie is set in their browser before our server redirects them to your website.

You need to place our tracking pixel on your thank you page. This will be the page where the desired action has been completed like "your order number is #" or "thank you for completing our survey". If the internet user buys something from your website or completes a lead action when shown this page the <img> tag will execute a script that checks the internet users computer for our cookie. If the cookie indicates that the user was sent from an affiliate's website our system will credit the affiliate and debit your account for the respective amount due.


This is how that works.

user visits siteA
user clicks affliate link which goes to SiteB?url=siteC&id=afid (cookie is set on siteB with information from url and id)
User is redirected to siteC
User then goes through whatever on siteC lets just say a survey for now
User Completes the survey
User ends up on a page where it says Thank you for completing the survey
On this page you have your 1px web bug:
<img height="1" Width="1" src="http://siteB/tracker.php">
What this code now does is executes the tracker.php script on siteB
Tracker.php runs code from the siteB server which looks to see if a cookie for siteB is set (not a cookie for site a)
If the cookie is set it will store the information from the cookie into a database (some of them may have things you can add to the tracker.php query string like price or whatever for stores)

nonstop

10+ Year Member



 
Msg#: 3100152 posted 2:06 pm on Sep 30, 2006 (gmt 0)

yep thats exactly it, i found out the problem, IE needs a compact P3P privacy policy on the site otherwise it will block reading the cookie from the img tag. it works fine on firefox and opera.

thanks for the help

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved