@mfb opened this issue on July 22nd 2008

For legal reasons some websites cannot log IP addresses of website visitors. This may be due to privacy restrictions or other legal issues.

Is it possible to disable IP address logging in piwik? If not this would be a great feature to add. Anonymized IP address be recorded in the database as "0".

@mattab commented on July 28th 2008

Piwik needs to store IP in order to maximise chance of detecting unique visitors. Every web analytics logs this data anyway.

Piwik will NOT display these IPs in the user interface.

@mfb commented on July 28th 2008

Here's a plugin to anonymize IP addresses which seems to work just fine in my testing.

<?php
/**
 * Piwik - Open source web analytics
 * 
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
 * @version $Id$
 * 
 * @package Piwik_IPAnon
 */

/**
 * 
 * @package Piwik_IPAnon
 */
class Piwik_IPAnon extends Piwik_Plugin
{
    public function getInformation()
    {
        $info = array(
            'name' => 'IPAnon',
            'description' => 'IP anonymizer',
            'author' => 'Indybay',
            'homepage' => 'http://www.indybay.org/',
            'version' => '0.1',
            'LogStatsPlugin' => true, // this plugin must be loaded during the stats logging
        );

        return $info;
    }

    function getListHooksRegistered()
    {
        $hooks = array(
            'LogStats.newVisitorInformation' => 'logIPAnonymize',
        );
        return $hooks;
    }


    /**
     * IP Anonymizer
     */
    public function logIPAnonymize($notification)
    {
        $visitorInfo =& $notification->getNotificationObject();        
        $visitorInfo['location_ip'] = 0;
    }

}
@anonymous-piwik-user commented on July 28th 2008

If I see this correctly that plug-in would (severely) distort the statistics for users who disabled cookies or delete them, e.g. by closing the browser. When I looked through the Piwik code I saw a statement that used a query matching several details (including the IP) to find a returning visitor in case no ID cookie is set.

A way to anonymize the IP may be to use a one way hash function to encode it. But that would probably require changes at several places not just your logIPAnonymize() method?! On a side node: IMHO the IP can not be totally anonymized. Since there is a finite number of IPs, its theoretically possible to enumerate all hashes and look the IP up =)

Furthermore, this feature would only make sense if you also would modify the web server configuration. If I may ask: which websites are not allowed to log IPs? E.g. here in Germany there is no widely accepted law that prohibits the logging in a legal way (although there are several interpretable suggestions for this). On the contrary, some web sites may run into legal problems if they do not log the IP (copyright issues, online shops needing proof for a transaction).

@mfb commented on July 28th 2008

I'm new to Piwik but as far as I can tell, visitors without a cookie are identified via config_md5config (aka configurationHash), and whether or not you log it the IP address will still be a part of config_md5config, allowing visitors to be differentiated.

I definitely agree that there's a concern of the IP address being looked up; my method was to also anonymize some other parameters in the configurationHash. This makes the data set for the hash much larger, granted I'm not sure it's "good enough" for an entity determined to "crack" an IP.

@anonymous-piwik-user commented on July 9th 2009

I like this plugin. I updated it for the current version (0.4.x) (basically updating the trigger).

Not saving the IP adresses of your customers might not suit everyone, but please accept this as a plugin as there is definitely an audience for a plugin like this.

If there are any questions, direct them to me: alexander dot schwartz at gmx dot net

Regards, Alexander.

<?php
/**
 * Piwik - Open source web analytics
 * 
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
 * @version $Id$
 * 
 * @package Piwik_IPAnon
 */

/**
 * 
 * @package Piwik_IPAnon
 */
class Piwik_IPAnon extends Piwik_Plugin
{
    public function getInformation()
    {
        $info = array(
            'name' => 'IPAnon',
            'description' => 'IP anonymizer',
            'author' => 'Indybay',
            'homepage' => 'http://www.indybay.org/',
            'version' => '0.1',
            'TrackerPlugin' => true, // this plugin must be loaded during the stats logging
        );

        return $info;
    }

    function getListHooksRegistered()
    {
        $hooks = array(
            'Tracker.newVisitorInformation' => 'logIPAnonymize',
        );
        return $hooks;
    }


    /**
     * IP Anonymizer
     */
    public function logIPAnonymize($notification)
    {
        $visitorInfo =& $notification->getNotificationObject();        
        $visitorInfo['location_ip'] = 0;
    }

}

@robocoder commented on July 9th 2009

To reiterate comment:1, we aren't accepting this into Piwik core.

See #692 instead.

@mattab commented on July 9th 2009

please create a new ticket, package the plugin in a .zip that is ready for install, add a description like other tickets, and we will put it in the Third Party Plugin category. thanks! http://dev.piwik.org/trac/query?status=new&status=assigned&status=reopened&group=milestone&milestone=Third+Party+Piwik+Plugins&order=priority

This issue was closed on August 4th 2009
Powered by GitHub Issue Mirror