Click here to Skip to main content
Click here to Skip to main content

Tagged as

Get search key word from the referrer url.

, 15 Nov 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
This is a very simple way to do actually. Web developers are very much familiar to work with the referrer url. The HTTP_REFERER server variable return the referrer url. In this tips I will show how easily we can get the search key word from the referrer url.
Well, lets take an example, you have a web site and the people come to your site from a search engin (Google, Bing) and now you want to know which word are used for the search and which search engin are used as well.
public string GetSearchKeyWords(string strQuery)
    string result = "";
    string pattern = "\\b\\w*p=(?!u)\\w*\\b|\\b\\w*q=(?!u)\\w*\\b|\\b\\w*qs=(?!u)\\w*\\b"
            + "|\\b\\w*encquery=(?!u)\\w*\\b|\\b\\w*k=(?!u)\\w*\\b\\b\\w*qt=(?!u)\\w*\\b"
            + "|\\b\\w*query=(?!u)\\w*\\b|\\b\\w*rdata=(?!u)\\w*\\b|\\b\\w*search_word=(?!u)\\w*\\b"
            + "|\\b\\w*szukaj|terms=(?!u)\\w*\\b\\b\\w*text=(?!u)\\w*\\b|\\b\\w*wd=(?!u)\\w*\\b|\\b\\w*words=(?!u)\\w*\\b";
    foreach (Match m in Regex.Matches(strQuery, pattern)) {
        // get the matched string
        string x = m.ToString();
        x = x.Substring(1, x.Length - 1);
        // collect all text
        result += x;
    return result.Replace("=", "");



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Md. Marufuzzaman
Bangladesh Bangladesh
A highly experienced leader with successful track record of software development, product innovations, brand management and corporate communication etc. Some successful product innovations have also achieved and awards “Most Valuable Professional” (MVP) at 2010 and 2011 by and also selected as a mentor of Published over 100 technical articles in various software development resource sites (i.e.,, Microsoft MSDN, and IEEE & IBM (In progress)) and various IT Forums, Blogs etc.
Over ten years of professional experiences in ICT field having extensive experience in formulating corporate vision and long term strategy. Leading development related functions including design, development, services, data management and analytics, customer experience management, content services, digital analytics and optimization.
An individual with results-driven approach and relentless in pursuit of excellence from a business and organizational standpoint. Believes in transparency, commitment and teamwork.
Expertise: Software/Solution Architect, SaaS platform base application, Large scale win32/web based business software solutions, enterprise applications, integration, etc.
Technologies/Tools: Microsoft.Net version 05/08/10/12, Microsoft SQL Server version 7/2K/05/08/12 , Oracle version 10/11, MySql version 5.1, 5.5, PS2, Visual C#, R, VB.NET, ASP.NET, PHP, API, MVC, WebAPI , Add-In Visual Basic etc.,. I have also more than two years’ of strong experience in mobile-VAS (platform development).
Points of Interest: Technology and research & development especially focused on business functionalities and social business areas as well, few stuff including:
1.R&D on new techniques as required to increase business revenue.
2.Urban and rural sectors to improve people’s lifestyle, better medical facilities, education, social business etc., using innovative technical solutions.
3.Research and innovative product development.
Follow on   Twitter   LinkedIn

Comments and Discussions

GeneralI have just tried this script and it is only retuning the fi... PinmemberGuerrilla12313-Mar-11 15:35 
GeneralRe: Yes you are absolutely right...the url is valid and contain ... PinmentorMd. Marufuzzaman15-Mar-11 10:16 
GeneralReason for my vote of 5 Great tip :-) Pinmvpthatraja28-Nov-10 0:18 
GeneralReason for my vote of 5 Usefull Info Pinmemberbaskarcts23-Nov-10 7:00 
GeneralReason for my vote of 5 This is a good program. PinmemberLakshmi Narayana198722-Nov-10 18:44 
GeneralReason for my vote of 5 great Pinmemberevren22-Nov-10 2:43 
GeneralReason for my vote of 5 Good Work PinmemberAbdul Quader Mamun16-Nov-10 0:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150327.1 | Last Updated 15 Nov 2010
Article Copyright 2010 by Md. Marufuzzaman
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid