HomePeopleRAVEmanBlogsSite Statistic implementing. Parsing Referrers.
Welcome, Guest Log inRegistration
RAVEman Latest Blogs
 
Site Statistic. Yandex quest. 30, November, 2006   Posted By RAVEman Series of articles about writing own Site statistic. In this blog i will cover problems i had with Cyrillic language, and cover handling Yandex urls.... Comments (9)
Site Statistic implementing. Parsing Referrers. 28, November, 2006   Posted By RAVEman Analyzing queries from site's referrers links is very important for any promotion guy. I explain everything in high details.... Comments (6)
 
Site Statistic implementing. Parsing Referrers.
 
Author: RAVEman Date Posted: 28, November, 2006 3:56 AM Viewed: 58 times

Search engines drive the major traffic to the most web-sites. To promote your web-site it's not enough to just analyze your content, link structure, etc. Knowing site's visibility in search engines is quite important too. You can Google for site:allforpromotion.com to see how many pages where indexed – but it's far away of being all picture. Here we comes to analyzing SERP (search engine results page). You must have set the main keywords for your site – and checking that each day (isn't that truth, ah :) ). But you can't check all the key phrases – especially that has low frequency words. But millions of Internet users can.

So here we come to very important thing – keeping track of queries which were used in search engines to reach your site.

How to figure query?

When you do search in each search engine (e.g. “what is search engine") – that query will be added to URL of the page. It will become like that: http://www.google.com/search?hl=en&q=what+is+search+engine. So to original address Google (let's take Google for example), added parameter q= in which the query was written (white spaces where replaced with "+"). Other search engines doing the same way (but each of that has it’s own parameter name, like text= for Yahoo). See the List of all major search engines on our site.

So when guys do searching and click on link (hopefully yours) nothing special happens – he just goes to your site. But the previous URL is stored in the referrers of current http request, and you can take it from there.

Implementation of the algorithm in ASP.NET

EFEX Consulting uses ASP.NET platform for almost all of the projects. Why? Read "ASP.NET conquers the world" – it’s really clear and interesting.

Anyway, here’s how it should be done in ASP.NET 2.0:

HttpContext.Current.Request class (or just Request) containts all the current request information. Referrer’s information can be found in here: Request.UrlReferrer.

Step by step implementation.

Step 1. Figuring the search engine.

Which search engine it is – we need to get the domain information. Here’s peace of code.


string domain = GetDomain(Request.UrlReferrer.AbsoluteUri);

public string GetDomain(string url)
{
	if (url.IndexOf("//") >= 0)
	{
		url = url.Substring(url.IndexOf("//") + 2);
		if(url.IndexOf('/')>=0)
			url=url.Substring(0,url.IndexOf('/'));

		if(url.StartsWith("www."))
			url=url.Substring(4);
		return url;
	}
    return "";
}

Step 2. if the domain is search engine.

We check out our list – if this very domain is search engine, if yes select from our list name of parameter, which is used by search engine to store query (you should use database for that of course – for flexibility)

Step 3. Retrieving query from referrer string.


string word=GetQueryParam(Request.UrlReferrer.AbsoluteUri,wordParam);

public string GetQueryParam(string url, string param)
{
	int pos;
	pos=url.IndexOf('?'+param+'=');

	if(pos<0)
		pos=url.IndexOf('&'+param+'=');

	if(pos<0)
		return null;

	int end;
	end = url.IndexOf('&',pos+1);
	
	string searchWord ="";
	if (end < 0)
		searchWord = url.Substring(pos + param.Length, url.Length - pos - param.Length);
	else searchWord = url.Substring(pos + param.Length, end - pos - param.Length);
	
	return searchWord;
}

With English queries it’s all, but if you deal with Cyrillic texts – you will have some more troubles. I faced that while setting up our Handy Statistic on few Russian web-sites. I will tell you more about that in next blog, and also will explain few ideas – how statistic system can be done.

If you have any questions / suggestions – feel free to send me an email to ravemans@yandex.ru

Anton Raichuk aka RAVEman
Chief System Architect
Efex Consulting



Back to Blogs Listing
 


Blog Comments
 
Received from Guest at 8/20/2008 10:09:13 AM radiographer sesquitertia irresponsibleness sutler pollster plebeity panocha peribronchiolar Gary Harvego's Photography
http://www.renault.com/gb/passion/collection.cfm?page=61951_4CVLeMans
Webs Within Reach
http://www.gumbley.net/diocese.htm
Shoji Ueda Museum of Photography
http://www.englishsolutions.us/
Surplus Shed
http://www.valleyofthekings.org/vofk/
Received from Guest at 2/9/2008 1:41:20 AM http://airline-38-585.kanikul.net http://airline-43-334.kanikul.net http://airline-12-507.kanikul.net http://airline-ticket-3-673.kanikul.net http://airline-31-152.kanikul.net http://airline-34-138.kanikul.net http://airline-2-475.kanikul.net http://airline-ticket-1-358.kanikul.net http://airline-16-132.kanikul.net http://airline-121.kanikul.net http://airline-5-372.kanikul.net http://airline-42-765.kanikul.net http://airline-3-798.kanikul.net http://airline-19-542.kanikul.net http://airline-ticket-7-635.kanikul.net http://airline-8-862.kanikul.net http://airline-ticket-9-868.kanikul.net http://airline-ticket-5-812.kanikul.net http://airline-25-176.kanikul.net http://airline-37-108.kanikul.net
http://airline-6-122.kanikul.net
Received from Guest at 2/9/2008 1:41:05 AM http://airline-19-542.kanikul.net http://airline-23-104.kanikul.net http://airline-10-617.kanikul.net http://airline-2-475.kanikul.net http://airline-26-486.kanikul.net http://airline-35-586.kanikul.net http://airline-3-798.kanikul.net http://airline-24-606.kanikul.net http://airline-ticket-6-160.kanikul.net http://airline-7-246.kanikul.net http://airline-29-601.kanikul.net http://airline-ticket-5-812.kanikul.net http://airline-ticket-2-363.kanikul.net http://airline-43-334.kanikul.net http://airline-13-168.kanikul.net http://airline-ticket-128.kanikul.net http://airline-43-693.kanikul.net http://airline-4-4.kanikul.net
http://airline-36-690.kanikul.net
Received from Guest at 9/5/2007 3:40:46 AM
Received from Guest at 4/27/2007 7:01:33 PM In my mind, it's really good article!
Received from Guest at 4/27/2007 7:00:18 PM
 


Add new Comment
 
Author: Guest Date Posted: 8/20/2008 11:25:56 PM