View Full Version : Rerering Script
nikomou
10-14-2005, 05:33 PM
Hi There, does anyone know of a script that will show the keywords used to find your site from a searche engine.
E.g. if i found www.dynamicdrive.com my typing "dynamic drive" into google, is it possible to have a script that will show this on the page? (i'm using html pages)
var st = document.referrer;
if(st.indexOf("google") > -1) {
st = st.substr(st.indexOf("q=") + 2);
st = st.substr(0, st.indexOf("&") > 1 ? st.indexOf("&") : st.length);
st = unescape(st.replace(/\+/g, " "));
document.write("Google search terms: " + st);
} else document.write("You haven't come from Google.");
nikomou
10-14-2005, 08:10 PM
Thanks,
I forgot to mention that I will need the keywords to be used inside a link
(http://www.mysite.com/thispage.asp?keyword=Google Search Term)
I also have the following script
<script type="text/javascript">document.write("http://www.mysite.com/thispage.asp?keyword=" + document.referrer);</script>
But it wont work if I place this as the href.
Any ideas?
Then you must document.write the whole link. document.write("<a href=\"http://www.mysite.com/thispage.asp?keyword=" + escape(st) + "\">Click Hyar</a>").
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.