Command-line utility for blocking referrer spam from your Google Analytics accounts
Google Analytics referrer spam is pain. ga-spam-control is a small command-line utility that helps you to keep your Google Analytics spam filters up-to-date.
ga-spam-control fetches the latest list of referrer spam domains from github.com/ddofborg/analytics-ghost-spam-list and creates or updates filters in your Google Analytics accounts that prevent any of these spam domains from reaching your analytics reports.
The command line utility provides the following actions:
- Action: status Display the spam-control status of all your accounts or for a specific account
- Action: update Create or update spam-control filters for an accounts
- Action: remove Remove spam-control filters from an account
ga-spam-control <command> [<args> ...]
ga-spam-control --help
Display the current spam-control status for all accounts that you have access to:
ga-spam-control status
Display the spam-control status in a parsable format:
ga-spam-control status -q
ga-spam-control status --quiet
Print account IDs of accounts that have the spam-control status of "not-installed"
ga-spam-control status -q | grep "not-installed" | awk '{print $1}'
Display the current spam-control status for a specific Google Analytics account:
ga-spam-control status <accountID>
update the spam-control filters for a specific Google Analytics account:
ga-spam-control update <accountID>
remove the spam-control filters for a specific Google Analytics account:
ga-spam-control remove <accountID>
Authentication
The first time you perform an action, you will be displayed an oAuth authorization dialog.
If you permit the requested rights the authentication token will be stored in your home directory (~/.ga-spam-control
).
To sign out you can either delete the file or de-authorize the "Google Analytics Spam Control" app in your Google App Permissions at https://security.google.com/settings/security/permissions.
The command-line package is github.com/andreaskoch/ga-spam-control/cli. You can clone the repository or install it with go get github.com/andreaskoch/ga-spam-control
and then run the make script:
go run make.go -test
go run make.go -install
go run make.go -crosscompile
or
make test
make install
make crosscompile
ga-spam-control is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
There are multiple curated lists of referrer spam domains out there that you can use to create filters for your analytics accounts.
- Analytics ghost spam list
- Piwik Referrer spam blacklist
- Referrer Spam Blocker Blacklist
- Stevie Ray: apache-nginx-referral-spam-blacklist
- My own list of referral spam domains
ga-spam-control is not the first and not the only tool that helps you to block referrer spam from your Google Analytics accounts.
Filters prevent referrer spam from getting into your Google Analytics accounts. But filters don't help you with referrer spam that already reached your reports. In order to filter this spam out you can use segments that filter out the spammy traffic:
Google Analytics has a setting to block bots and spiders from your Google Analytics reports.
- Goto
Google Analytics > Admin > Account > Property > View > View Settings
- Goto
Bot Filtering
- Check
Exclude all hits from known bots and spiders
This feature is not advertised much by Google. The only time it officially got mentioned by is in a Google Plus post: Google Analytics - Introducing Bot and Spider Filtering.
I am not yet sure if this flag does the trick. One would assume that is would be easy for Google to exclude all referrer spam and block the stupid spammers once and for all.