diff --git a/core/Common.php b/core/Common.php index 9b1c954f4f1df8e784e3f5d87d24761f3d2e73de..fb44d2c7ffdb135d1b83b9224e6284a8eb79cfc6 100644 --- a/core/Common.php +++ b/core/Common.php @@ -1385,8 +1385,11 @@ class Piwik_Common if($searchEngineName === 'Google Images' || ($searchEngineName === 'Google' && strpos($referrerUrl, '/imgres') !== false) ) { - $query = urldecode(trim(self::getParameterFromQueryString($query, 'prev'))); - $query = str_replace('&', '&', strstr($query, '?')); + if (strpos($query, '&prev') !== false) + { + $query = urldecode(trim(self::getParameterFromQueryString($query, 'prev'))); + $query = str_replace('&', '&', strstr($query, '?')); + } $searchEngineName = 'Google Images'; } else if($searchEngineName === 'Google' && (strpos($query, '&as_') !== false || strpos($query, 'as_') === 0)) @@ -1415,6 +1418,21 @@ class Piwik_Common $key = trim(urldecode(implode(' ', $keys))); } + if ($searchEngineName === 'Google') + { + // top bar menu + $tbm = self::getParameterFromQueryString($query, 'tbm'); + switch ($tbm) + { + case 'isch': + $searchEngineName = 'Google Images'; break; + case 'vid': + $searchEngineName = 'Google Video'; break; + case 'shop': + $searchEngineName = 'Google Shopping'; break; + } + } + if(empty($key)) { foreach($variableNames as $variableName) diff --git a/core/DataFiles/SearchEngines.php b/core/DataFiles/SearchEngines.php index 1368cea8c596638d71fbfc0618eec543c08d98a7..a619f66803a7937a36f5e67c4d962efa098bef78 100644 --- a/core/DataFiles/SearchEngines.php +++ b/core/DataFiles/SearchEngines.php @@ -433,7 +433,7 @@ if(!isset($GLOBALS['Piwik_SearchEngines'] )) 'google.com/custom' => array('Google Custom Search'), 'google.{}/custom' => array('Google Custom Search'), - // Google translation + // Google Translation 'translate.google.com' => array('Google Translations', 'q'), // Google Images @@ -444,13 +444,16 @@ if(!isset($GLOBALS['Piwik_SearchEngines'] )) 'news.google.com' => array('Google News', 'q'), 'news.google.{}' => array('Google News'), - // Google product search - 'froogle.google.com' => array('Google Product search', 'q'), - 'froogle.google.{}' => array('Google Product search'), + // Google Shopping + 'google.com/products' => array('Google Shopping', 'q', '?q={k}&tbm=shop'), + 'google.{}/products' => array('Google Shopping'), // Google syndicated search 'googlesyndicatedsearch.com'=> array('Google syndicated search', 'q'), + // Google Video + 'video.google.com' => array('Google Video', 'q', 'search?q={k}&tbm=vid'), + // Google Wireless Transcoder // - does not appear to execute JavaScript // 'google.com/gwt/n' => array('Google Wireless Transcoder'), diff --git a/tests/core/Common.test.php b/tests/core/Common.test.php index c97f34b285a63ee2d620a8931ffae01ea83544bf..d961caeb729eb668e3f5a6095f8028422225e288 100644 --- a/tests/core/Common.test.php +++ b/tests/core/Common.test.php @@ -727,6 +727,12 @@ class Test_Piwik_Common extends UnitTestCase 'http://www.google.com/imgres?imgurl=http://www.piwik-connector.com/en/wp-content/themes/analytics/images/piwik-connector.png&imgrefurl=http://www.piwik-connector.com/en/&usg=__ASwTaKUfneQEPcSMyGHp6PslPRo=&h=700&w=900&sz=40&hl=en&start=0&zoom=1&tbnid=K7nGMPzsg3iTHM:&tbnh=131&tbnw=168&ei=r9OpTc1lh96BB4bAgOsI&prev=/images%3Fq%3Dpiwik%26hl%3Den%26safe%3Doff%26biw%3D1280%26bih%3D828%26gbv%3D2%26tbm%3Disch&itbs=1&iact=rc&dur=1400&oei=r9OpTc1lh96BB4bAgOsI&page=1&ndsp=23&ved=1t:429,r:0,s:0&tx=125&ty=88' => array('name' => 'Google Images', 'keywords' => 'piwik'), + 'http://www.google.com/search?tbm=isch&hl=en&source=hp&biw=1280&bih=793&q=piwik&gbv=2&oq=piwik&aq=f&aqi=g5g-s1g4&aql=&gs_sm=e&gs_upl=1526l2065l0l2178l5l4l0l0l0l0l184l371l1.2l3l0' + => array('name' => 'Google Images', 'keywords' => 'piwik'), + + 'http://www.google.fr/imgres?q=piwik&um=1&hl=fr&client=firefox-a&sa=N&rls=org.mozilla:fr:official&tbm=isch&tbnid=Xmlv3vfl6ost2M:&imgrefurl=http://example.com&docid=sCbh1P0moOANNM&w=500&h=690&ei=3OFpTpjvH4T6sgbosYTiBA&zoom=1&iact=hc&vpx=176&vpy=59&dur=299&hovh=264&hovw=191&tx=108&ty=140&page=1&tbnh=140&tbnw=103&start=0&ndsp=39&ved=1t:429,r:0,s:0&biw=1280&bih=885' + => array('name' => 'Google Images', 'keywords' => 'piwik'), + // Google CSE is not standard google 'http://www.google.com/cse?cx=006944612449134755049%3Ahq5up-97k4u&cof=FORID%3A10&q=piwik&ad=w9&num=10&rurl=http%3A%2F%2Fwww.homepagle.com%2Fsearch.php%3Fcx%3D006944612449134755049%253Ahq5up-97k4u%26cof%3DFORID%253A10%26q%3D89' => array('name' => 'Google Custom Search', 'keywords' => 'piwik'), @@ -753,6 +759,10 @@ class Test_Piwik_Common extends UnitTestCase 'http://www.google.com/imgres?imgurl=http://www.softwaredevelopment.ca/software/wxtest-red.png&imgrefurl=http://www.softwaredevelopment.ca/wxtestrunner.shtml&usg=__feDWUbLINOfWzPieVKX1iN9uj3A=&h=432&w=615&sz=18&hl=en&start=0&zoom=1&tbnid=V8LgKlxE4zAJnM:&tbnh=143&tbnw=204&ei=w9apTdWzKoLEgQff27X9CA&prev=/images%3Fq%3Dbook%2Bsite:softwaredevelopment.ca%26um%3D1%26hl%3Den%26safe%3Doff%26client%3Dubuntu%26channel%3Dfs%26biw%3D1280%26bih%3D828%26as_st%3Dy%26tbm%3Disch&um=1&itbs=1&iact=hc&vpx=136&vpy=141&dur=19894&hovh=188&hovw=268&tx=124&ty=103&oei=w9apTdWzKoLEgQff27X9CA&page=1&ndsp=3&ved=1t:429,r:0,s:0' => array('name' => 'Google Images', 'keywords' => 'book site:softwaredevelopment.ca'), + // Google Shopping + 'http://www.google.com/search?q=cameras&tbm=shop&hl=en&aq=f' + => array('name' => 'Google Shopping', 'keywords' => 'cameras'), + // Google cache 'http://webcache.googleusercontent.com/search?q=cache:CD2SncROLs4J:piwik.org/blog/2010/04/piwik-0-6-security-advisory/+piwik+security&cd=1&hl=en&ct=clnk' => array('name' => 'Google', 'keywords' => 'piwik security'),