SitePoint Sponsor

User Tag List

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

    Pass Keyword Phrase in Form

    Is there a way to grab the keyword phrase that people used to enter the website, determine if it was from an organic or paid search, and then post the keyword phrase and type of search in two hidden form fields? Anyone have example code or have done this before?

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,037
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Do you mean that your visitor is entering from a search engine and you would like to trap the terms that they used to find your site?

    There probably is a way of doing it but you'll likely have to do some testing from different search engines and check the referrer header to see if the search engine leaves a trail of information.

    Try a search like: vbscript referrer search engine terms
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development

  3. #3
    SitePoint Addict
    Join Date
    Dec 2001
    Posts
    395
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Basically the client is looking to find out if the form was submitted from someone visiting from either a search engine or a paid search engine. Then they want to know the keyword the visitor used to find the website. Is this possible and how can it be accomplished?

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,037
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    You can probably get it from the information that is sent in the http header but it would be much easier to use a decent analytics program to get the information.

    • AWStats will do it by accessing the server's log files and grabbing the information.
    • Google Analytics will do it if you insert a snip of javascript in the bottom of the page which it uses to track the activities of the visitor's browser, where they came from and what they looked at.

    AWStats is a free program and many hosting companies provide it as a standard feature in their hosting packages. Google Analytics is free too but you need to have a GMail address to set it up and use it.
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development

  5. #5
    SitePoint Addict
    Join Date
    Dec 2001
    Posts
    395
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your response. Unfortunately the client is looking to have this information sent as part of the form so the keywords and type of search are part of the email.

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,037
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Ok, that's what I thought might have been the case. I think you'll have to do some R&D to figure this one out. An idea comes to mind.

    Find the information in the HTTP header. You can test it out by putting the following code in a page that you know can be accessed via a search engine. Go to the search engine, click on the link and then review the information that can be found in the source code.

    HTML Code:
    <!--
    THE FOLLOWING INFORMATION WILL ONLY BE SEEN IN THE SOURCE CODE
    <%= request.ServerVariables("ALL_HTTP") %>
    -->
    I just tried this and it will work but you'll have to sift through the information to string to make it actually work. I pulled a header that looks like this:
    HTTP_REFERER:http://www.google.ca/search?q=my_search_term&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-USfficial&client=firefox-a
    Armed with this information you can use VBScript to search the string and get the search term and you can also search it for the search engine as well. You'll have to try it against other search engines like yahoo, Ask, Moreover, etc... to see how they deal with search terms, etc...

    Here's Yahoo's:
    HTTP_REFERER:http://search.yahoo.com/search?p=my_search_term&ei=UTF-8&fr=moz35
    You get the referrer through request.ServerVariables("HTTP_REFERER")

    I just had another thought and that is that you might be able to get this information through JavaScript.

    Good luck.
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development


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
  •