PHP what page directed users to mine?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Shepp001
Forum Newbie
Posts: 1
Joined: Wed Dec 01, 2010 1:57 pm

PHP what page directed users to mine?

Post by Shepp001 »

Hi all,,

Does anyone know any code that will allow me to tell what page/site/search engine brought users to my page.

So for example if someone typed a keyword into google... and clicked onto my website.. how would i tell : a.) that is was from google.. and b.)What the keyword(s) were

Or... if someone clicked on a link on a different website, to mine, how would i be able to tell what site they came from.?

Is this possible or not? :? if so any help would be appreciated :D

Thankss

- Luke
curlybracket
Forum Commoner
Posts: 59
Joined: Mon Nov 29, 2010 2:40 pm

Re: PHP what page directed users to mine?

Post by curlybracket »

http://www.google.com/analytics/

It's free and gives huge set of statistics of every kind.
matt1234
Forum Commoner
Posts: 44
Joined: Wed Nov 26, 2008 9:43 pm

Re: PHP what page directed users to mine?

Post by matt1234 »

You could setup a table in a database that records $_SERVER['HTTP_REFERER'] which will show you the URL of the page visited just prior to your's.
Try doing

Code: Select all

echo $_SERVER['HTTP_REFERER'];
to see what you will see. And if you do it that way, you'll be able to pick out what the person typed into google based on the URL
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: PHP what page directed users to mine?

Post by social_experiment »

From the PHP manual : 'HTTP_REFERER' : The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply