There's a plugin for Wordpress called rthanks which you can set up in your posts. It basically says you came to our site through Google, Yahoo, Stumbleupon, etc. Anyways, I'm working on an SE landing page and wanted to add the same sort of script, but haven't been able to find anything yet. Does anybody have a link or any reference for this? John Batttelle has a great one on his blog that not only says what SE they came from, but what keyword they entered to wind up at that page. That script would really be ideal. I've been looking for the past couple days to find something like this I can use to no avail. Anybody have an alternative? It doesn't have to be Javascript, I just assumed there would be a js script like this out there.
It's quite easy, how much do you know about coding ?? I'm pretty busy right now, but heres how it's done ... You simply collect data on the format of search queries from each search engine , for example for google the keyword is stored in _GET[q] so if a users HTTP_REFERER is something like google.co.uk/?search=blah&q=pants you know that user came from google and the keyword they used was pants. Same for all other search engines and later on if no one posts I'll write what you need .... EDIT: JS has document.referer also, you can split document.referer by ?, [0] is the url and [1] is the query string, then split [1] by &, then split all of that array by = and you're left with the key => value same as _GET in php, or whatever ....
I see what you're saying, but I don't write a lot of Javascript. Your heading me in the right direction though. Basically, I want the script to live in a sidebar that says something like this. Hello there Google User, You've come to our site using Google searching for pants. -Suggested link -Suggested link -Suggested link I think your explanation is just outside of my realm of understanding, but thanks for the reply. I'm gonna see if I can hack it out.
This is the rthanks script I'm trying to reverse engineer. Originally this was created to live on a php page like header.php or where ever you wish for this info to show up. I'm trying to work this into a Javascript I can put on individual html pages.
And that still stands, there's nothing I can do about that, there are also some browsers that don't send referer information, again, nothing I can do about that either ....
Here's the code I'm using...no luck yet. I'm also trying this by referencing an outside js file. <script type="text/javascript"> <!-- function refer_thanks() { if (preg_match('/^http:\/\/(\w+\.)?(hellobmw)\./',$_SERVER['HTTP_REFERER']) == 0 && $_SERVER['HTTP_REFERER'] != NULL) { preg_match('@^(?:http://)?([^/]+)@i',$_SERVER['HTTP_REFERER'], $matches); $host = $matches[1]; echo "<p style='background-color:#FFFEC6; border:thin dashed #CFCFCF; padding:6px; font-size:12px; color:#666;'>Welcome friends from <strong>{$host}</strong> ! <br />If you are the first time here, please subscribe my <a href='".get_option('home')."/feed/'>RSS feed</a><br /> Thank you!</p>"; } } --> </script> HTML:
Try looking at google's page analytics script - http://www.google-analytics.com/urchin.js - there's a nice big list of search engines and query strings in there with a neat little function that returns which engine it was, '_uOrg'. The variable names are obfuscated but spend a little time reading through it and you'll get how it works