Click here to Skip to main content
13,458,430 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


20 bookmarked
Posted 15 Nov 2010

Get search key word from the referrer url.

, 15 Nov 2010
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 well 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 twelve 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.I have also more than two years’ of strong experience in mobile-VAS (platform development).

An individual with results-driven approach and relentless in pursuit of excellence from a business and organizational standpoint.Honest, believes in transparency, commitment and teamwork.

Expertise: Software/Solution Architect, Research, MIS, Data Analytics, Data Mining, BI, SaaS platform base application development, Large scale Win32 Form/Web based business software solutions, Security, Enterprise applications development, integration, etc.

Technologies/Tools: Microsoft.Net version 05/08/10/12, Microsoft SQL Server version 7/2K/05/08/12/14 , Oracle version 10/11, MySql version 5.1, 5.5, 5.7, Visual C#, VB.NET, ASP.NET, API, MVC, WebAPI , WPF, WCF, PHP, Microsoft Power BI, SPSS, PS2, R, Add-In, Visual Basic etc.

.Net UI component: Telerik, DevExpress, Ext.Net.
Scripting language: JavaScript, AngularJS, node.JS.
Source control / Subversion: Git,SVN.
Development methodologies: Agile,RAD.
Project Management / Issues Tracking Tools: JIRA, ClockingIt.

You may also be interested in...

Comments and Discussions

GeneralI have just tried this script and it is only retuning the fi... Pin
Guerrilla12313-Mar-11 14:35
memberGuerrilla12313-Mar-11 14:35 
GeneralRe: Yes you are absolutely right...the url is valid and contain ... Pin
Md. Marufuzzaman15-Mar-11 9:16
mentorMd. Marufuzzaman15-Mar-11 9:16 
GeneralReason for my vote of 5 Great tip :-) Pin
thatraja27-Nov-10 23:18
mvpthatraja27-Nov-10 23:18 
GeneralReason for my vote of 5 Usefull Info Pin
baskarcts23-Nov-10 6:00
memberbaskarcts23-Nov-10 6:00 
GeneralReason for my vote of 5 This is a good program. Pin
Lakshmi Narayana198722-Nov-10 17:44
memberLakshmi Narayana198722-Nov-10 17:44 
GeneralReason for my vote of 5 great Pin
evren22-Nov-10 1:43
memberevren22-Nov-10 1:43 
GeneralReason for my vote of 5 Good Work Pin
Abdul Quader Mamun15-Nov-10 23:46
memberAbdul Quader Mamun15-Nov-10 23:46 

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

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

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