Forum Moderators: coopster

Message Too Old, No Replies

Using HTTP_REFERER to track product pages

Can this be done or are they issues that i need to consider?

         

Alina

4:26 pm on May 20, 2005 (gmt 0)

10+ Year Member



Hello

We are trying to "include" a left hand side (LHS) menu on all our product pages, where one of the links within the LHS menu is an enquiry link. If we do this, we will not be able to determine which product page using the LHS menu was calling the enquiry link. That is we will not be able to use a link like: [mysite...]

If the product pages were called sensible names for example greenWidget.php - would it be ok for me to look at HTTP_REFERER within the enquiry page in order to record which product page was calling it?

if a visitor came from a search engine and arrived on a product page, to get to the enquiryform they would still need to click on the enquiry link on the LHS menu. So the HTTP_REFERER would be reset to the product page (i think?)

It appears to work ok, but i was wondering (because i am no expert) whether there was perhaps something that i have not thought about, and should consider?

Many thanks for your help

Alina

StuffOfInterest

6:55 pm on May 20, 2005 (gmt 0)

10+ Year Member



You can't rely on HTTP_REFERER to be set. Some broswers and proxy servers don't send the information. Some browsers may send the wrong referer information.

You could try using a cookie, but some browsers will block the cookie. This is why PHP session tracking and phpBB session tracking use URL request variables information

Your best bet would be to pass the information as part of the URL as in:

moreinfo.php?productid=999

This will set the global variable "$_GET['productid']" to "999" which you can use for tracking.

Alina

12:45 pm on May 24, 2005 (gmt 0)

10+ Year Member



Hi

What i am referring to are, local pages on the server - after a visitor has landed - that are calling the enquiry page. I have done a check and saw that HTTP_REFERER was being set correctly.

Would what you are saying - still be a problem? If a visitor is viewing a webpage - after landing, wouldn't our server then be setting HTTP_REFERER?

Many thanks for you help

Alina

gliff

12:59 pm on May 24, 2005 (gmt 0)

10+ Year Member



Would what you are saying - still be a problem? If a visitor is viewing a webpage - after landing, wouldn't our server then be setting HTTP_REFERER?

Yes, it would still be a problem. The HTTP_REFERER field is dependant on the client (browser) and proxy servers, all of which are out of your control. So even after a user has landed, the referer may be blank.

Alina

1:23 pm on May 24, 2005 (gmt 0)

10+ Year Member



Hi Thanks for your reply. Do you know of a variable that i could use in order to know which page was calling the enquiry form?

StupidScript

9:27 pm on May 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$_SERVER["PHP_SELF"]

or

$_SERVER["SCRIPT_NAME"]

then something like

$q=$_SERVER["QUERY_STRING"];

$p=$_SERVER["SCRIPT_NAME"];

$thislink="enquiry.php?".$q."&camefrom=".$p."&otherstuff ... ";

echo "<a href='".$thislink."'>Link</a><br />\n";

On the enquiry page, grab

$_SERVER["camefrom"]
as your "referrer".

(BTW, to paraphrase gliff: Not all browsers/users allow the referrer to be passed, which is what makes it unreliable: it may or may not be there to see.)

Alina

9:36 pm on May 24, 2005 (gmt 0)

10+ Year Member



many thanks. Will try this.