Author Topic: Exclude pages/urls from statistics  (Read 3065 times)

0 Members and 1 Guest are viewing this topic.

simik

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Exclude pages/urls from statistics
« on: May 21, 2012, 01:19:27 AM »
I have installed a theme which supports customization of layout, colors and other stuff, which is implemented via dynamic PHP-generated CSS and JS files. These files are displayed by StatPress as separate pages, so for every legitimate page shown another two (CSS and JS) get counted. Is there any way to exclude pages/urls, and if not, would you consider adding this feature?

forumadmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 92
  • Karma: +1/-0
    • View Profile
    • Wordpress Ready
Re: Exclude pages/urls from statistics
« Reply #1 on: May 21, 2012, 09:36:28 AM »
Hi simik:
Currently StatComm 1.6.90 filters most common regular extensions, but the user can't change it (yet , but it will shortly). These extensions are .ico, .css,.js, .jpg,.jpeg,.png and .gif.

Certainly we miss the case of CSS / JS / (pick your extension here)  PHP-generated, and we also know this is fairly common scenario (even we made some themes using this concept).

Filtering pages from the traffic it is very interesting indeed so we already added to request's list. It is very likely it would come with two options: filter the traffic directly (without saving to the database) and/or filtering from the views (saving it but no displaying it).

Thinking forward we can quickly add a feature where you could control what exactly want to filter out before saving to the database. In this way we would solve your request, although you would need to add a couple of lines to the theme function to start filtering pages. The good news is you will be in full control of the filter and it can be implemented in the next version.

Being said, with a great power comes a great responsibility. You should be aware of few things:
  • The filter function would impact in the overall capture process performance. So the faster is the filter, the better.
  • If the filter gets a programming glitch, the plugin could stop capturing records or even worst , stop the entire site. Be sure to test it in a safe environment.
  • What you filter, you won't save it, so be careful.
  • A more friendly approach will be implemented on future versions, but isn't scheduled yet (we are just scheduling your idea remember :) and we have to make room for it ) . The friendly approach will combine filtered pages from user interface with those coming from the filter, so it should be future-compatible.

We'll add code samples to show how this filter would work.

Best Regards
Fernando





simik

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Exclude pages/urls from statistics
« Reply #2 on: May 21, 2012, 10:38:52 AM »
Thanks for such a detailed answer. I've modified your code and added a couple lines after your extension check to filter out these particular CSS/JS requests (these requests look like itx=css&ver=1.2.3, that's why they were not filtered out by your extension check). It's a dirty hack but it will do till you implement user-defined filters.

forumadmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 92
  • Karma: +1/-0
    • View Profile
    • Wordpress Ready
Re: Exclude pages/urls from statistics
« Reply #3 on: May 21, 2012, 12:52:45 PM »
Great. I glad you made it.
Don't worry about the hack, with the next version you will adapt easily the code to the examples.

Best regards.
Fernando


forumadmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 92
  • Karma: +1/-0
    • View Profile
    • Wordpress Ready
Re: Exclude pages/urls from statistics
« Reply #4 on: June 02, 2012, 08:11:20 PM »
In StatComm version 1.7.01 we added a new capability using statcomm_preinsert filter.
The filter gives the possibility to filter data before saving and also discard it just returning null or empty string ('').

We expect to publish some additional information in these days along with some examples.

Best Regards
Fernando

simik

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Exclude pages/urls from statistics
« Reply #5 on: June 04, 2012, 02:41:20 AM »
Well, that's a start. Still need coding to filter out unwanted pages. And where should I add my custom filter function, make a custom plugin for it?

For now I just added this code to the end of your main plugin file (statcomm.php):
Code: [Select]
add_filter('statcomm_preinsert', 'ignoreITXThemeFiles', 99, 1);

function ignoreITXThemeFiles( $scu ) {
  if ( $scu->getUrlrequested() &&
       preg_match( '/^itx=(css|js)&ver=[0-9.]+$/i', $scu->getUrlrequested() )
     )
       return null;

  return $scu;
}

I would much prefer a text field in plugin's opions with a list of regexes to filter out.

forumadmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 92
  • Karma: +1/-0
    • View Profile
    • Wordpress Ready
Re: Exclude pages/urls from statistics
« Reply #6 on: June 04, 2012, 02:28:26 PM »
Thanks for your comments. We didn't have enough time to publish examples as we are writing it right this time :o .
Great work though, that is a very fine example.
The filter can be added to the current theme in functions.php as well the statcomm_info action. That should be enough.

Next iteration is focusing on plugin performance and after that we are working to make the plugin multisite. In between , we'll provide an easy way to include filters and other settings as you suggest.


Best Regards
Fernando