PDA

View Full Version : How do we exclude local file(s) for the stats?


dondon
08-08-2011, 09:46 PM
Hi,

For development purpose, I do something like the following often,
file:///C:/KN_website_v3/download_dev4.html
and yet, it also counts into the stats...
It would be nice to exclude such local testing from the stats, possible?
How?

Whereas, we know, the above corresponding live one would be
'http://www.knowledgenotebook.com/download_dev4.html'

Thanks in advance.

webado
08-09-2011, 12:59 AM
Well as long as you are connected to the internet, it's going to log the hit to whatever page the tracker is on, whether local or not.

You can play a bit with the script so it won't get executed when it's local.

dondon
08-09-2011, 03:37 AM
Well, what if we have an additional var in addition to the following, say,
'sc_state' of int type, and default to 1 (online only), 2 (both online and offline/local)
var sc_projec
var sc_invisible
var sc_security

Just a thought...

webado
08-09-2011, 03:53 AM
Detect the url being accessed and decide what to do if it's not on your own domain example.com.

I'd maybe use a different project to log such hits.

dondon
08-09-2011, 12:13 PM
" use a different project to log such hits." would be a nightmare to the development/deployment process because your locally tested code can't be deployed directly.

The idea of a new var of 'sc_state' or the like probably should be construed as a new feature request something...

webado
08-09-2011, 12:33 PM
I don't have this problem and I develop locally, on locallhost.

If blocking your IP address does not help (it won't if you don't have a fixed IP), then this is one of your best choices, because blocking by cookie will not work locally either.

The tracker is meant to log hits to any page regardless where it is found and this is by design. This is one way you can find out if somebody has been copying your content. Or at least your tracking code.

If you are no good with scripting here's perhps a simpler method.

Put the code for the on-page javascript into an external js file and call it something like my-sc.js, without the <script ....> and </script> tags, only the executable javascript code (so only the project number, security, invisibility lines).

Include the script this way on your pages:

<script type="text/javascript" src="my-sc.js"></script>

Upload that js file to the server and remove it from your local folder or hide it in another folder not in the same path).

When you view your pages locally, that js file is not there, so Statcounter cannot log anything anywhere because it does not have the project details. Ignore any js error you'd see due to that or a counter image saying Invalid project or some such.

dondon
08-09-2011, 03:23 PM
No prob if you don't want to consider my new feature request. Let's let me rest it here!
This feature is not critical.

webado
08-10-2011, 12:50 AM
I neither consider nor not consider. I am giving you an easier option.

dondon
08-11-2011, 01:48 PM
Out of curiosity, are you one of the founders/developers of this web app?

Arne
08-11-2011, 03:49 PM
Out of curiosity, are you one of the founders/developers of this web app?

No, she is not. Like me and other moderators, we are just voluntary moderators and members in the forum, and users of the counter service.
And like other forum members we help when and where we can, give ideas and discuss Statcounter.

Re your feature request, Webado gave you on option that you may use if you like, until your request is eventually implemented, if it may be implemented.