Forum Moderators: coopster

Message Too Old, No Replies

Referer and keyword info sent via form?

and I thought this would be easy

         

vmills

7:51 pm on Jul 22, 2004 (gmt 0)

10+ Year Member



I'm an amatuer - maybe even remedial - PHP user, but I do have a script for sending form data via email, and I thought it would be a great idea to pass along data about referrers and keywords through hidden fields in the form.

I've learned that HTTP_REFERRER, at least in my tests, returns the page visted on the current domain before the form page, not the domain visited before the current domain, so that hasn't been useful. I don't know how I would get keywords in this case. I've searched around for scripts or tutorials and have been surprised to find nothing helpful

The site in question has a separate stats package, but it doesn't track converting keywords and that's really what I'm after. There isn't high volume traffic, so getting them individually via a form (rather than input into a database) isn't a problem.

My question is really whether what I'm trying to do is possible with a few lines of code, or have I underestimated the complexity of the task?

jatar_k

10:57 pm on Jul 22, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> HTTP_REFERRER, at least in my tests, returns the page visted on the current domain before the form page,

true, but if you only set the referrer in a session when they first hit the site and not reset it then you can grab it when they signup/purchase and get where they were referred from.

I do something like this and include it on every page

session_start();
if (!isset($_SESSION['referer']) ¦¦ empty($_SESSION['referer'])) $_SESSION['referer'] = $_SERVER['HTTP_REFERER'];

then in the form you can grab it from $_SESSION['referer'] and pop it into your form.

I also use source strings in paid marketing and I try to use this as well

if (isset($_GET['source']) && (!isset($_SESSION['campaign']) ¦¦ empty($_SESSION['campaign']))) $_SESSION['campaign'] = $_GET['source'];

You could also write that into a form.

The keywords will be in the referer string, I don't cut them up when i drop them into the session, I do all of that after the fact.

remember to replace all ¦ characters with real pipe characters

vmills

2:18 am on Jul 23, 2004 (gmt 0)

10+ Year Member



Well that certainly worked. Thanks so much!

I just have one more question. I know search engine robots get tangled up in session IDs. I tried testing this with cookies disabled and I didn't see any IDs in the URL. I also ran it through a "spider simulation" site and didn't find any problems.

I'm not used to writing sessions myself, so I'm not sure if this particular usage will impact search engine spiders, but I need to be sure that it doesn't - or find a workaround if it does.

jatar_k

4:04 pm on Jul 23, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



as long as the session vars aren't required for the pages to be viewed and PHPSESSID comes up in the url then you're good to go.

The robots just refuse the cookie and still get all the content, they are happy and so are you. ;)

vmills

8:29 pm on Jul 23, 2004 (gmt 0)

10+ Year Member



Thanks. I am happy.