Forum Moderators: coopster
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?
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
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.