See Additional Results in Search Engine Referrers Module for Drupal
The search Engine Referrers module for Drupal is a module that allows you to see recent search engine queries that led visitors to your website. As the module's project page on Drupal states, the Search Engine Referrers module is intended to be very simple and lightweight. It does not create additional database tables or log entries. It simply provides a display of certain existing data already stored in Drupal.
The module's settings allow you to see up to 50 most recent entries per search engine. We currently use a modified version of the module on Web New Castle. You may find that if you only check statistics periodically (like us) or if you have a high volume, you want to see more than it's current limit.
The following is an example of additional code that will allow you to set a specific number of entries to skip so that you can see more history of search engine referrers. Please note this is just a "bare bones" post and not an example of how to modify and customize a Drupal module. This is not an illustration of how to customize a module "the Drupal way", and it is not an example of how we develop and customize modules. This is just a simple post about a code change with PHP and SQL to do perform one specific task and as an example.
In the search_engine_referrers.module file, you will find at the bottom a section that begins with a note: "Form generating function for search_engine_referers settings". After the closing parenthesis and semicolon that follows the line containing "#default_value", you can add something like the following:
$form['search_engine_referers_skip_num'] = array(
'#type' => 'textfield',
'#title' => t('Number of entries to skip'),
'#default_value' => variable_get('search_engine_referers_skip_num', 0),
);
This creates a simple textfield to let you put in a number of entries to skip. Because of where this has been placed (within a particular form), the field will show up automatically after the existing drop down setting that comes with the module.
Two more things are necessary to make this all work. Farther up in the code, after multiple lines related to specific search engines, there is a line beginning with "$num = intval ..... ". After that line you can something like the following:
$skipnum = intval(variable_get('search_engine_referers_skip_num', 0));
And then finally, you would need to update the database query to use all of this. Otherwise, it's all pointless. The code for the database queries is just a few lines down and begins with "$result = db_query_range ...". In this line, at the very end you will see "0, $num);". If you replace the zero with $skipnum, this will complete the change. You will now have a simple way to put in whatever number of entries you want to have skipped so that you can see additional history of search engine referrers to your site.
Again, this is a simple illustration and not a tutorial on the accepted and recommended way of modify modules. Even if recommend coding practices aren't important to you, the drawback of directly modifying the code of a module is that the code is gone when you update the module.







Post new comment