SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Dec 2001
    Posts
    395
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get Keyword and Redirect

    Is it possible in JavaScript to grab the keyword phrase that people use to enter a website from a search engine or paid search engine. Then use that data to redirect the visitor to the correct page on the website depending on the keyword phrase?

    For example if keyword 1 contains "word1" in the keyword phrase automatically redirect to page1.html. If keyword 2 contains "word2" in the keyword phrase automatically redirect to page2.html.

    Does anyone know how to do this? Any help would be greatly appreciated!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,719
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Rockwilda View Post
    Is it possible in JavaScript to grab the keyword phrase that people use to enter a website from a search engine or paid search engine. Then use that data to redirect the visitor to the correct page on the website depending on the keyword phrase?
    I believe that document.referrer can provide that info.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Addict
    Join Date
    Dec 2001
    Posts
    395
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can document.referrer be used?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,719
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Rockwilda View Post
    How can document.referrer be used?
    You use document.referrer to retrieve a string that contains the path the person came from.

    Code javascript:
    var referrer = document.referrer;

    Which in the case of my viewing this particular thread, is:
    "http://www.sitepoint.com/forums/forumdisplay.php?f=15"

    Then you use standard string manipulation techniques to retrieve the information you want from that string.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •