Group results by keywords or search engine
mgifford - March 28, 2007 - 14:14
| Project: | Search Keywords |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Jump to:
Description
Would be great to have the results from this broken down by both search engine & keywords. Would be nice to be able to focus on google (.com, .ca, .uk or all of the above), or on your own search pages. Would be good to know how often in the last 4 weeks someone came to your site with the phrase "drupal consulting" for instance.
Knowing how well a search phrase ranks in a respective search engine could also be useful. As it is right now it takes a lot of time to scroll through to find out useful information about what people are searching for that is driving them to your site.
Nice module though.
Mike

#1
Ok, I was getting a little frustrated by not being able to dig through and find out more about the keywords that were being used for my site.. This patch allows you to sort by a number of elements. search engine, keyword, path, etc. However, I've really only built the interface to work off the search_engine and keyword. Had to move around the link logic a bit so that people could more easily access this new information.
--- /tmp/search_keywords.module 2007-04-05 17:48:56.000000000 -0400
+++ search_keywords.module 2007-04-05 19:41:18.000000000 -0400
@@ -86,8 +86,29 @@
array('data' => t('Path'), 'field' => 'a.path'),
);
- $sql = 'SELECT a.* FROM {search_keywords_log} a' . tablesort_sql($header);
+ // Add search queries
+ $where = '';
+ if (arg(3) && arg(4)) {
+ switch (arg(3)) {
+ case 'search_engine':
+ $where .= " WHERE a.search_engine LIKE '%" . arg(4) . "%' ";
+ break;
+ case 'title':
+ $where .= " WHERE a.title LIKE '%" . arg(4) . "%' ";
+ break;
+ case 'path':
+ $where .= " WHERE a.path LIKE '%" . arg(4) . "%' ";
+ break;
+ case 'url':
+ $where .= " WHERE a.url LIKE '%" . arg(4) . "%' ";
+ break;
+ case 'keywords':
+ $where .= " WHERE a.keywords LIKE '%" . arg(4) . "%' ";
+ break;
+ }
+ }
+ $sql = 'SELECT a.* FROM {search_keywords_log} a' . $where . tablesort_sql($header);
$result = pager_query($sql, 30);
while ($log = db_fetch_object($result)) {
$title = (empty($log->title))?$log->path:$log->title;
@@ -99,10 +120,14 @@
if (!_search_keywords_is_utf8($log->keywords)) {
$log->keywords = _search_keywords_to_utf8($log->keywords);
}
+ $keyword_links = '';
+ foreach(split(' ', $log->keywords) as $word) {
+ $keyword_links .= l($word, 'admin/logs/search_keywords/keywords/' . $word) . ' ';
+ }
$rows[] = array(
array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'),
- array('data' => l($log->search_engine, "http://$log->search_engine/")),
- array('data' => "$flag" . l($log->keywords, $log->url)),
+ array('data' => l($log->search_engine, 'admin/logs/search_keywords/search_engine/' . $log->search_engine) . ' ' . l('*', "http://$log->search_engine/")),
+ array('data' => "$flag " . $keyword_links . ' ' . l('*', $log->url)),
array('data' => l(_search_keywords_column_width(decode_entities($title)), $log->path)));
}