Hack: Google (Search Engine) from which country

Hello all,

I already hacked PHPMV to get more detailed informations about google search engine.

i need to know from which country come the visitor (google.fr, google.ch, google.com.do etc).

in order to do so, i altered the source code of two files:

./piwik/plugins/Referers/function.php (line 27)

	function Piwik_getSearchEngineLogoFromName($url)
		require_once "DataFiles/SearchEngines.php";
	 	//special hack google  
		if(substr($url, 10, 6)=="google"||substr($url,7, 6)=="google"||substr($url,8, 6)=="google"||substr($url,11, 6)=="google"||substr($url,12, 6)=="google"){
			$path = 'plugins/Referers/images/searchEngines/%s.png';  
			$beginningUrl = strpos($url,'//') + 2;
			$normalPath = sprintf($path, substr($url,$beginningUrl));
			$normalPath = sprintf($path, 'www.google.com');
			$path = 'plugins/Referers/images/searchEngines/%s.png';
			$beginningUrl = strpos($url,'//') + 2;
			$normalPath = sprintf($path, substr($url,$beginningUrl));
	//$path = 'plugins/Referers/images/searchEngines/%s.png';
	//$beginningUrl = strpos($url,'//') + 2;
	//$normalPath = sprintf($path, substr($url,$beginningUrl));

	// flags not in the package !

./piwik/core/DataFiles/SearchEnginges.php (line 329)

		// Google
		"gogole.fr"				=> array("Google.fr", "q"),
		"www.gogole.fr"			=> array("Google.fr", "q"),
		"wwwgoogle.fr"			=> array("Google.fr", "q"),
		"ww.google.fr"			=> array("Google.fr", "q"),
		"w.google.fr"			=> array("Google.fr", "q"),
		"www.google.fr"			=> array("Google.fr", "q"),
		"www.google.fr."		=> array("Google.fr", "q"),
		"google.fr"				=> array("Google.fr", "q"),
		"www2.google.com"		=> array("Google.com", "q"),
		"w.google.com"			=> array("Google.com", "q"),
		"ww.google.com"			=> array("Google.com", "q"),
		"wwwgoogle.com"		    => array("Google.com", "q"),
		"www.gogole.com"		=> array("Google.com", "q"),
		"www.gppgle.com"		=> array("Google.com", "q"),
		"go.google.com"			=> array("Google.com", "q"),
		"www.google.ae"			=> array("Google.ae", "q"),
		"www.google.as"			=> array("Google.as", "q"),
		"www.google.at"			=> array("Google.at", "q"),
		"wwwgoogle.at"			=> array("Google.at", "q"),
		"www.google.az"			=> array("Google.az", "q"),
		"w.google.at"			=> array("Google.at", "q"),
		"www.google.be"			=> array("Google.be", "q"),
		"www.google.be"			=> array("Google.be", "q"),
		"www.google.bg"			=> array("Google.bg", "q"),
		"google.bg"				=> array("Google.bg", "q"),
		"google.bg"				=> array("Google.bg", "q"),
		"www.google.bi"			=> array("Google.bi", "q"),
		"www.google.ca"			=> array("Google.ca", "q"),
		"ww.google.ca"			=> array("Google.ca", "q"),
		"w.google.ca"			=> array("Google.ca", "q"),
		"www.google.cc"			=> array("Google.cc", "q"),
		"www.google.cd"			=> array("Google.cd", "q"),
		"www.google.cg"			=> array("Google.cg", "q"),
		"www.google.ch"			=> array("Google.ch", "q"),
		"www.google.ch"			=> array("Google.ch", "as_q"),
		"ww.google.ch"			=> array("Google.ch", "q"),
		"www.google.ci"			=> array("Google.ci", "q"),
		"www.google.ci"			=> array("Google.ci", "q"),
		"www.google.cl"			=> array("Google.cl", "q"),
		"www.google.co"			=> array("Google.co", "q"),
		"www.google.co"			=> array("Google.co", "q"),
		"www.google.cz"			=> array("Google.cz", "q"),
		"wwwgoogle.cz"			=> array("Google.cz", "q"),
		"www.google.de"			=> array("Google.de", "q"),
		"ww.google.de"			=> array("Google.de", "q"),
		"wwwgoogle.de" 			=> array("Google.de", "q"),
		"wwwgoogle.de" 			=> array("Google.de", "q"),
		"www.googleearth.de" 	=> array("Google.de", "q"),
		"googleearth.de"		=> array("Google.de", "q"),
		"www.google.dj"			=> array("Google.dj", "q"),
		"google.hr"				=> array("Google.hr", "q"),
		"www.google.dk"			=> array("Google.dk", "q"),
		"www.google.dz"			=> array("Google.dz", "q"),
		"www.google.es"			=> array("Google.es", "q"),
		"www.google.fi"			=> array("Google.fi", "q"),
		"www.google.fm"			=> array("Google.fm", "q"),
		"www.google.gg"			=> array("Google.gg", "q"),
		"www.google.gl"			=> array("Google.gl", "q"),
		"www.google.gm"			=> array("Google.gm", "q"),
		"www.google.gr"			=> array("Google.gr", "q"),
		"www.google.gp"			=> array("Google.gp", "q"),
		"google.gr"				=> array("Google.gr", "q"),
		"www.google.hn"			=> array("Google.hn", "q"),
		"www.google.hr"			=> array("Google.hr", "q"),
		"google.hr"				=> array("Google.hr", "q"),
		"www.google.ie"			=> array("Google.ie", "q"),
		"www.google.it"			=> array("Google.it", "q"),
		"www.google.it"			=> array("Google.it", "q"),
		"www.google.kz"			=> array("Google.kz", "q"),
		"www.google.kz"			=> array("Google.kz", "q"),
		"www.google.li"			=> array("Google.li", "q"),
		"www.google.lt"			=> array("Google.lt", "q"),
		"www.google.lu"			=> array("Google.lu", "q"),
		"www.google.lv"			=> array("Google.lv", "q"),
		"www.google.ms"			=> array("Google.ms", "q"),
		"www.google.mu"			=> array("Google.mu", "q"),
		"www.google.mw"			=> array("Google.mw", "q"),
		"www.google.nl"			=> array("Google.nl", "q"),
		"www.google.nl"			=> array("Google.nl", "q"),
		"www.google.no"			=> array("Google.no", "q"),
		"www.google.pl"			=> array("Google.pl", "q"),
		"www.google.pn"			=> array("Google.pn", "q"),
		"www.google.pn"			=> array("Google.pn", "q"),
		"www.google.pt"			=> array("Google.pt", "q"),
		"www.google.ro"			=> array("Google.ro", "q"),
		"www.google.ro"			=> array("Google.ro", "q"),
		"www.google.ru"			=> array("Google.ru", "q"),
		"www.google.rw"			=> array("Google.rw", "q"),
		"www.google.se"			=> array("Google.se", "q"),
		"www.google.sh"			=> array("Google.sh", "q"),
		"www.google.sn"			=> array("Google.sn", "q"),
		"www.google.sk"			=> array("Google.sk", "q"),
		"www.google.sm" 		=> array("Google.sm", "q"),
		"www.google.td"			=> array("Google.td", "q"),
		"www.google.tt"			=> array("Google.tt", "q"),
		"www.google.uz"			=> array("Google.uz", "q"),
		"www.google.vg"			=> array("Google.vg", "q"),
		"www.google.com.ar"		=> array("Google.com.ar", "q"),
		"www.google.com.au"		=> array("Google.com.au", "q"),
		"www.google.com.bo"		=> array("Google.com.bo", "q"),
		"www.google.com.br"		=> array("Google.com.br", "q"),
		"www.google.com.by"		=> array("Google.com.by", "q"),
		"www.google.com.co"		=> array("Google.com.co", "q"),
		"www.google.com.cu"		=> array("Google.com.cu", "q"),
		"www.google.com.do"		=> array("Google.com.do", "q"),
		"www.google.com.do"		=> array("Google.com.do", "q"),
		"www.google.com.ec"		=> array("Google.com.ec", "q"),
		"www.google.com.fj"		=> array("Google.com.fj", "q"),
		"www.google.com.gr" 	=> array("Google.com.gr", "q"),
		"www.google.com.hk"		=> array("Google.com.hk", "q"),
		"www.google.com.hk"		=> array("Google.hk", "q"),
		"www.google.com.ly"		=> array("Google.com.ly", "q"),
		"www.google.com.mt"		=> array("Google.com.mt", "q"),
		"www.google.com.mx"		=> array("Google.com.mx", "q"),
		"www.google.com.my"		=> array("Google.com.my", "q"),
		"www.google.com.nf"		=> array("Google.com.nf", "q"),
		"www.google.com.ni"		=> array("Google.com.ni", "q"),
		"www.google.com.np"		=> array("Google.com.np", "q"),
		"www.google.com.pa"		=> array("Google.com.pa", "q"),
		"www.google.com.pe" 	=> array("Google.com.pe", "q"),
		"www.google.com.ph"		=> array("Google.com.ph", "q"),
		"www.google.com.pk"		=> array("Google.com.pk", "q"),
		"www.google.com.pl"		=> array("Google.com.pl", "q"),
		"www.google.com.pr"		=> array("Google.com.pr", "q"),
		"www.google.com.py"		=> array("Google.com.py", "q"),
		"www.google.com.qa"		=> array("Google.com.qa", "q"),
		"www.google.com.ru"		=> array("Google.com.ru", "q"),
		"www.google.com.ru"		=> array("Google.com.ru", "q"),
		"www.google.com.sa"		=> array("Google.com.sa", "q"),
		"www.google.com.sg"		=> array("Google.com.sg", "q"),
		"www.google.com.sv"		=> array("Google.com.sv", "q"),
		"www.google.com.sv"		=> array("Google.com.sv", "q"),
		"www.google.com.tr"		=> array("Google.com.tr", "q"),
		"www.google.com.tw"		=> array("Google.com.tw", "q"),
		"www.google.com.ua"		=> array("Google.com.ua", "q"),
		"www.google.com.uy"		=> array("Google.com.uy", "q"),
		"www.google.com.vc"		=> array("Google.com.vc", "q"),
		"www.google.com.vn"		=> array("Google.com.vn", "q"),
		"www.google.co.cr"		=> array("Google.co.cr", "q"),
		"www.google.co.gg"		=> array("Google.co.gg", "q"),
		"www.google.co.hu"		=> array("Google.co.hu", "q"),
		"www.google.co.id"		=> array("Google.co.id", "q"),
		"www.google.co.il"		=> array("Google.co.il", "q"),
		"www.google.co.in" 		=> array("Google.co.in", "q"),
		"www.google.co.je"		=> array("Google.co.je", "q"),
		"www.google.co.jp"		=> array("Google.co.jp", "q"),
		"www.google.co.ls"		=> array("Google.co.ls", "q"),
		"www.google.co.ma" 		=> array("Google.co.ma", "q"),
		"www.google.co.ke" 		=> array("Google.co.ke", "q"),
		"www.google.co.kr"		=> array("Google.co.kr", "q"),
		"www.google.co.nz"		=> array("Google.co.nz", "q"),
		"www.google.co.th"		=> array("Google.co.th", "q"),
		"www.google.co.uk"		=> array("Google.co.uk", "q"),
		"www.google.co.ve"		=> array("Google.co.ve", "q"),
		"www.google.co.za" 		=> array("Google.co.za", "q"),
		"www.google.com"		=> array("Google.com", "q"),


Thanks Jool, for your work. It’s really needed sometimes to know this, but I’m saw so many scripts doing this… it’s not a problem in our time…)) But you code seems pretty well! style_emoticons/<#EMO_DIR#>/rolleyes.gif


i searched but didn’t found any similar request.
Will there be an option in future where i can tell piwik to open the keyword links (list of keywords) with the right google domain?
Now every keyword ist linked to google.com like this
and I could change this by editing the searchEngines.php (I know that) to get this link
The same for image search, etc.

But after every update I have to edit it again.
Maybe an option “for which country you like to use Piwik” would be a very nice thing. style_emoticons/<#EMO_DIR#>/cool.gif

You have done a great job an I’m looking forward that someday my wish will be granted.
So long…

I would really like to see the specific search engine people searched with (" Best search engine" and “List of keywords” widget). For example if some one searched with the uk version of google (www.google.co.uk). This makes a difference because for a certain keyword you might rank differently.