Dirty: Script to ignore Dynamic IP Adresses

I have a customer who has an dynamic ip, 10 PCs and hundreds of Users. The default profile gave them the piwik monitored site as a startpage, so they falsify the piwik statistic.

It was not (easy) possible to change this for existing users, nor could i set the ignore cookie stable for all Users.

I set up the script bellow on the server which is run every hour by cron.

It compares the Dynamic IP the Customer has (dyndns.org) with the IP stored in the Piwik konfiguration and updates it when needed.

I know that this is realy dirty but it might help someone.

Please note the security risk of putting the piwik mysql-pw in the script in cleartext.


This Script checks an Dynamic-IP and writes it into the Piwik-DB in order to ignore requests

from that IP

This will overwrite the List of IP-Adresses to be ignored in Piwik!!

Only Testest with Piwik 1.6 on Debian

Use at your own Risk

Be carefull with the Access rights to this script as the piwik-db-passsword has to be put in

Plaintext into this Script.




logger “Update DynIP $sitename in Piwik-DB:”

altip=mysql -p$password -u $username -D $dbname --execute="SELECT excluded_ips from site WHERE name = '$sitename' \g \q" | tail -n 1
logger "Old-IP: $altip"
neuip=host $dynipname | awk '{print $3}'
logger “New-IP: $neuip”

if [ “$neuip” = “$altip” ] ; then
logger "Nothing to do"
exit 1
logger "Update IP in Piwik-DB"
mysql -p$password -u $username -D $dbname --execute="update site SET excluded_ips=’$neuip’ WHERE name = ‘$sitename’ \g \q"
logger "Test Success…"
altip=mysql -p$password -u $username -D $dbname --execute="SELECT excluded_ips from site WHERE name = '$sitename' \g \q" | tail -n 1
if [ “$neuip” = “$altip” ] ; then
logger "Update successfull"
exit 0
logger "Error while updating"
exit 2

Nice! seems like the only solution so far.

I wrote a summary of all “exclude traffic by hostname”- related posts over at
Make Global list of Excluded IPs accept domains ?
in that post, there’s also a solution mentioned using a shell-script.
So maybe add new posts there.

Anyone know if this script will work with the latest version of piwik (v2.5.0)?

After all this time, I can’t believe there’s not a plugin or easier way to exclude via DDNS. At the moment, I need to refresh the cookie on multiple devices when checking stats.

Hm. As far as I know there is no plugin yet to do this.
Maybe you could create a ticket for that on github.

Thanks @SteveG, I’ve opened an Issue on GH: Ability to exclude visitors using Dynamic DNS DDNS · Issue #6046 · matomo-org/matomo · GitHub

There’s now a (not so dirty) plugin, called ExcludeByDDNS (currently in alpha, but it works).
It can be installed via the marketplace.
It’s homepage is

For more and further discussions on the topic, see

I think it’s better to do further posts there.