diff --git a/search_api_stats.install b/search_api_stats.install
index 661bd21..f6ee453 100644
--- a/search_api_stats.install
+++ b/search_api_stats.install
@@ -130,4 +130,15 @@ function search_api_stats_schema() {
   );
 
   return $schema;
+}
+
+function search_api_stats_update_7001(&$sandbox) {
+  $lang = array(
+    'description' => 'The {languages}.language of this node.',
+    'type' => 'varchar',
+    'length' => 12,
+    'not null' => TRUE,
+    'default' => '',
+  );
+  db_add_field('search_api_stats','language',$lang);  
 }
\ No newline at end of file
diff --git a/search_api_stats.module b/search_api_stats.module
index ee026b7..e78c6c0 100644
--- a/search_api_stats.module
+++ b/search_api_stats.module
@@ -12,7 +12,11 @@
  */
 function search_api_stats_search_api_query_alter(SearchApiQueryInterface $query) {
 
-  global $user;
+  global $user, $language;
+
+  //get configure infomation
+  $config = variable_get('search_api_stats_block_config', array());
+  $path = $config['solr']['solr_node_index']['path'];
 
   // Assign some object variables to avoid chained member access.
   $index = $query->getIndex();
@@ -21,20 +25,25 @@ function search_api_stats_search_api_query_alter(SearchApiQueryInterface $query)
   }
 
   // Fail out if there's no valid index or server objects to work from.
-  if (empty($index) || empty($server)) {
+  if (empty($index) || empty($server) || $path != current_path()) {
     return;
   }
-
-  $log = array(
-    's_name' => $server->machine_name,
-    'i_name' => $index->machine_name,
-    'timestamp' => REQUEST_TIME,
-    'uid' => $user->uid,
-    'sid' => session_id(),
-    'keywords' => trim(drupal_strtolower($query->getOriginalKeys())),
-    'filters' => '',
-    'sort' => '',
-  );
-
-  drupal_write_record('search_api_stats', $log);
+  
+  $keywords = trim(drupal_strtolower($query->getOriginalKeys()));
+  //to avoid to insert empty keywords value into database.
+  if(!empty($keywords)) {
+    db_insert('search_api_stats')
+      ->fields(array(
+        's_name' => $server->machine_name,
+        'i_name' => $index->machine_name,
+        'timestamp' => REQUEST_TIME,
+        'uid' => $user->uid,
+        'sid' => session_id(),
+        'keywords' => $keywords,
+        'filters' => '',
+        'sort' => '',
+        'language' => $language->language
+      ))
+      ->execute();
+    }
 }
\ No newline at end of file
