PHP tracking a visitor

I have a website that has multiple "Partner" pages on the site.  If a customer comes to the site (Enters the site) through a partner page and ends up making a purchase, how do I track that customer so as that I know the customer came from a specific partner page?
The reason for this is that the specific partner get's a credit.
LVL 8
rgranlundAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark BradyPrincipal Data EngineerCommented:
When a user clicks a link to an outside domain/website that link should include a referer. For example, if the referrer domain is xyz.com and your url is yourdomain.com/sales then the referer should program their link like so.

<a href="http://www.yourdomain.com/sales?referer=xyz.com">Click here</a>

Open in new window


On your site you should parse out the arguments and look for the referer.

$referer = $_GET['referer'];

Then you will know where they came from. That is an easy way of doing it. There are other ways as well. PHP has a $_SERVER['HTTP_REFERER']

This is typically set in the request headers. They are sometimes empty though like if someone directly comes to your site by typing in the url then these will be empty. Also if someone accesses your site programatically (cURL) they may be empty.

The easiest way is to ask your referrers to add the referer=xyz.com to the link
Ray PaseurCommented:
... a website that has multiple "Partner" pages on the site.
The fact that the partner pages are on the same site is key.  Your partner pages can set a cookie.  When the purchase occurs, the cookie will tell you whether or which partner provided the referral.  You will want to consider how to give credit when a purchaser has visited more than one of the partner pages and then makes a purchase, but that's a business decision, not a technical one.

Here's what you need to know:
http://php.net/manual/en/features.cookies.php

If there is any chance that the partner pages are not on the same site, then the correct design is to give every partner referral link a separate URL on your site.  This will have a similar effect to adding a URL parameter, but it might be a little easier to follow in Google webmaster tools.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgranlundAuthor Commented:
@Ray, after I read the article and did further research,  I decided to use the $_SESSION variable.  I works 100% the way I want it to.  Thanks Ray.
Ray PaseurCommented:
Great - thanks for the points and best of luck with it! ~Ray
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.