# YBlog - Hide Yourself to your Analytics
Keywords: analytics, statistics, hide, blog, jQuery, javascript

French ↓ Menu ↓

# Hide Yourself to your Analytics

This is a way not to count your own visits to your blog. First you should look on how I handle analytics. All analytics are handled in one javascript file, this make things really convenient.

Then you need to know my method use the `jquery-cookie`.

I check if the key `admin` is not set in the cookie before adding the visit.

        var admin = $.cookie('admin');
        if (! admin) {
            // put your analytics code here
        } else {
            console.log("[WARNING] you're HIDDEN to analytics");
        }

then create two <sc>html</sc> files. One to hide:

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <script type="text/javascript" src="jquery.js"></script>
            <script type="text/javascript" src="jquery.cookie.js"></script>
            <script>
                $(document).ready(function(){
                    $.cookie('admin',1);
                    $('#info').html('Analytics can no more see you.')
                });
            </script>
            <title>Hide to analytics</title>
        </head>
        <body>
            <div id="info"></div>
        </body>
    </html>

the other to be visible again (it can be useful):

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <script type="text/javascript" src="jquery.js"></script>
            <script type="text/javascript" src="jquery.cookie.js"></script>
            <script>
                $(document).ready(function(){
                    $.cookie('admin',null);
                    $('#info').html('Analytics can see you.')
                });
            </script>
            <title>Hide to analytics</title>
        </head>
        <body>
            <div id="info"></div>
        </body>
    </html>

Now accessing these files with you browser you can hide or appear in your statistics. You just have to think to access these file from all you browser.

RSS · Tweet · FB
These social sharing links preserve your privacy
↑ Top ↑
Published on 2010-06-17
Follow @yogsototh
Yann Esposito©
Done with Vim spacemacs & nanoc Hakyll

ADA: `DdzFFzCqrhtAvdkmATx5Fm8NPJViDy85ZBw13p4XcNzVzvQg8e3vWLXq23JQWFxPEXK6Kvhaxxe7oJt4VMYHxpA2vtCFiP8fziohN6Yp`