Results 1 to 4 of 4

Thread: Rerering Script

  1. #1
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Referer Script

    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)
    Last edited by nikomou; 10-14-2005 at 05:41 PM. Reason: Spelling - Title

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    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.");
    Last edited by Twey; 10-15-2005 at 12:00 PM. Reason: Made the regex global.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    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?

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Then you must document.write the whole link. document.write("<a href=\"http://www.mysite.com/thispage.asp?keyword=" + escape(st) + "\">Click Hyar</a>").
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •