Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture Keywords 1

Status
Not open for further replies.

esteiner

Programmer
Oct 31, 2003
24
0
0
I have noticed that several of our competitor sites are somehow able to "capture" a user's keyword phrase used to generate the search engine results pages and populate the exact phrase into a textbox on a form.

I would like to do the same thing as it would greatly improve the usability of our site. I am fairly proficient in ASP and HTML, but not much else. I am very willing to learn something new if it would result in the best solution. I am working in a windows environment.

Any help on getting started would be appreciated.

Thank you,

-cdogz

 
while I'm not sure how it would improve usability, as the user should have landed on the most relevant page on your site anyway (assuming correct optimisation). Simply pull it from the querystring,

Google = request.querystring("q")
MSN = request.querystring("q")
Yahoo = request.querystring("p")

Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
Nightclub counting systems

So long, and thanks for all the fish.
 
Thank, Chris, I appreciate the tip. I would like to a follow up question if you don't mind.

Where did you learn this? I would like learn more about how to interact with search engines using ASP. I am able to get by (with examples) in ASP, but obviously do not have alot of experience. We are a small company with no real IT staff. I have to wear alot of hats! Is there a book or another resource that you recommend?

For example, I would like to know how to detect which search engine the user is entering from so that I can use the correct request.querystring("x") for all of the major search engines. I also would like to conceal this code so that someone can't just copy it.

Thanks again for your help. I really appreciate it.

P.S.

We sell over 50,000 different products and most of our visitors find us by searching for the product part number. Some of the part numbers can be very long. Being able to capture the part number and populate a form with it helps the user avoid errors.

-Charlie
 
Most of my working time is taken up ensuring that clients websites are found by the search engines for the right keywords, and the code I write is not causing problems for the crawlers and SE indexing. so I have to make sure that I am up to date with SEs. There is a forum here for SEO forum828 and there are a few here who are clued up on SEs.
The two resources I would recommend are HighRankings and IHelpYou. There are lots of other forums and resources around but often the information is based on myth and quick fixes rather than long term results. (full disclosure. I am a Mod at both these forums so I would be recommending them [lol]).

Code:
<%
dim hostname 
dim refer
dim querystring
dim search
hostname = lcase(request.servervariables("HOSTNAME"))
refer = lcase(request.servervariables("HTTP_REFERER"))
querystring = lcase(request.servervariables("QUERY_STRING"))

if refer <> "" or instr(refer,hostname) > 0 then
   if instr(refer,"google") > 0 or instr(refer,"msn") > 0 then 
      search = request.querystring("q")
   end if 
   if instr(refer,"yahoo") > 0 then
      search = request.querystring("p")
   end if
end if
%>
Not tested btw but should work ok

Product numbers and Mfr's ref Nos are excellent for search results and ROI. I've found that 60% - 80% of searchers who find the site with one of these will buy the product. And very few sites use them as target keywords.

I see the idea now, to fill in the order form as the users hit the page.



Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
Nightclub counting systems

So long, and thanks for all the fish.
 
Thank you very much for you advice.

Will this identify all search engines, not just Google, Yahoo, and MSN? The majority of our users are from outside our country.

Thanks again, you have been a great resource.

-Charlie
 
as it is only those three are captured but to add more only needs more of these lines

Code:
   if instr(refer,"engine") > 0 then
      search = request.querystring("parameter")
   end if

and to find the parameter you can check your server logs or go to the engine and run a search, then look at the URL in the address bar.


Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
Nightclub counting systems

So long, and thanks for all the fish.
 
maybe something to do with this error on your page

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Request.Collection'

/server.asp, line 44

Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
Nightclub counting systems

So long, and thanks for all the fish.
 
I am trying several thing, you just caught me a bad moment. try again Please. Here is the cose I use:

<%

Dim VariableName
Response.write(Request.ServerVariables("HTTP_REFERER")&"<br><br>" )
Response.write("XXX=" & Request.querystring("q"))
Response.Write "<TABLE Border=1 BorderColor=""BBBBBB"">"
Response.Write " <TR>"
Response.Write " <TD><B>Server Variable Name</B></TD>"
Response.Write " <TD><B>Server Variable Value</B></TD>"
Response.Write " </TR>"

For Each VariableName In Request.ServerVariables

Response.Write "<TR>"
Response.Write " <TD>&nbsp;" & VariableName & "</TD>"
Response.Write " <TD>&nbsp;"
Response.write Request.ServerVariables(VariableName)
Response.Write " </TD>"
Response.Write "</TR>"

Next

Response.Write "</TABLE>"

%>
<%
dim hostname
dim refer
dim querystring
dim search
hostname = lcase(request.servervariables("HOSTNAME"))
refer = lcase(request.servervariables("HTTP_REFERER"))
querystring = lcase(request.servervariables("QUERY_STRING"))

if refer <> "" or instr(refer,hostname) > 0 then
if instr(refer,"google") > 0 or instr(refer,"msn") > 0 then
search = request.querystring("q")
end if
if instr(refer,"yahoo") > 0 then
search = request.querystring("p")
end if
end if
'RESPONSE.WRITE(SEARCH)

%>

Steve
 
Google has to have the page in the index to be able to link to it.

The querystring will only get sent from Google via a SERP click.

Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
Nightclub counting systems

So long, and thanks for all the fish.
 
Ahhhhhhhhhhhhh, I did that!! I am displaying the referrer in the top. The url I have pasted here if from there. Do you see the last parameter? It's the q I am looking for.
Sop, why can't I use it?

here is the link again. Click, the click click on the link in google. Please.



Steve
 
Look at the link.

Because Google doesn't have the page indexed there is no querystring parameters attached to the link.
It hasn't been found for any query. It is placed on the page as a suggestion, therefore no querystring.






Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
Nightclub counting systems

So long, and thanks for all the fish.
 
aha! I really should have tested that code before posting it. DOH!

The "Q" from the SEs is not in the querystring, it's part of the referer.

Bit of recoding needed, watch this space.

Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
Nightclub counting systems

So long, and thanks for all the fish.
 
Ok. Wrote this as a set of functions and added a bit on.
Code:
<%
' function library include for search word extraction

function CaptureKeywords(strIn,strMarker)
dim startPoint
dim endPoint
dim temp
strMarker = strMarker & "="
startPoint = instr(strIn,strMarker)
if startPoint > 0 then 
endPoint = instr(startPoint,strIn,"&") ' instr(strIn,"&") 'instr(strIn,"&")
temp = mid(strIn,startPoint + len(strMarker),len(strin) - instr(startPoint,strIn,"&"))
if endpoint <> 0 then temp = left(temp,instr(temp,"&") - 1)
else
temp = ""
end if
CaptureKeywords = temp
end function

function URLDecode(strIn)
    dim i
    dim strRet
    dim temp

    if len(strIn) > 0 then

        for i = 1 to len(strIn)
            temp = mid(strIn, i, 1)
            temp = replace(temp, "+", " ")
            If temp = "%" and len(strIn) > i + 2 then
                temp = mid(strIn, i + 1, 2)
                temp = chr(cint("&H" & temp))
                i = i + 2
            end if
            strRet = strRet & temp
        next
        URLDecode = strRet
    end if
end function

function ExtractSearch()
dim hostname 
dim refer
dim search
dim strMarker
hostname = lcase(request.servervariables("HOSTNAME"))
refer = lcase(request.servervariables("HTTP_REFERER"))

if refer <> "" or instr(refer,hostname) > 0 then
   if instr(refer,"google") > 0 or instr(refer,"msn") > 0 then 
      strMarker = "q"
   end if 
   if instr(refer,"yahoo") > 0 then
      strMarker = "p"
   end if
end if
ExtractSearch = URLDecode(CaptureKeywords(refer,strMarker))
end function

function ExtractSearchEngine()
dim hostname 
dim refer
dim search
dim strMarker

hostname = lcase(request.servervariables("HOSTNAME"))
refer = lcase(request.servervariables("HTTP_REFERER"))

if refer <> "" or instr(refer,hostname) > 0 then
   if instr(refer,"google") > 0 then 
      ExtractSearchEngine = "Google"
   end if 
   if instr(refer,"msn") > 0 then 
      ExtractSearchEngine = "MSN"
   end if 
   if instr(refer,"yahoo") > 0 then
      ExtractSearchEngine = "Yahoo"
   end if
else
      ExtractSearchEngine = ""
end if

end function

%>

to use
Code:
<%
with response
	.write ExtractSearchEngine()
	.write "<br><br>"
	.write ExtractSearch()
end with
%>



Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
Nightclub counting systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top