Google Analytics is great for gathering data on who uses your web
application, but becomes worthless if spam sessions start infesting your
data. Here’s how we’ve tried to combat the problem for oddbird.net.
Like many websites, we use Google Analytics to gather data about our
users – what OS and browser they used, how they came to our site, etc.
But a number of months ago we started seeing lots ofthis:
It’s not a new problem, but it’s particularly problematic for smaller
sites that don’t receive lots of traffic. On a given day, spam hits were
accounting for anywhere from ten to ninety (!) percent of oursessions.
There are many solutions out there; since we mostly saw spam in the
“referral” field, we wanted a simple way to block spam referrals from
being included in our analyticsdata.
One common approach is to disallow any site visits where
document.referrer matches a known spam domain. There are free
services that create the necessary Google Analytics “filters” for you,
but they must be re-configured frequently as new spammers are added to
This approach has worked relatively well – in the first two weeks, we
only saw nine spam sessions sneak through. But we weren’t entirely
thrilled with it,either.
First of all, a disallowed-list of domains-to-block is much more difficult to
maintain than an allowed-list of domains-to-allow (even if we’ve off-loaded
most of the maintenance to the community). And second, there’s something
less-than-ideal about fetching a raw .txt file directly from someone
else’s GitHub repo, making assumptions about the format of the file
contents, and then relying on it as part of our build/deployprocess.
Learn how to leverage Web Platform Tests to ensure your polyfills are implementing upcoming browser features correctly, including how to generate a comprehensive report of failing/passing tests on each change.
OddBird sponsored Python Web Conference 2023 and sent me to attend. In this article I showcase my favorite talks and activities from this excellent online event, including a list of useful resources for web application security, introductions to new PaaS providers, and a comparison of the most popular Python web frameworks.