If you’re a user of any synthetic speed testing service, you’ll likely have many browsers visiting your site every day – testing your site speed from various locations, devices, etc. That’s not a big deal if it’s just a few daily tests, but if you’re a power user then your visitor analytics, such as in Google Analytics, will report a higher than accurate session count, attributed as ‘Direct Traffic’. This could be misleading.
Good news is there’s an easy way to filter these out.
WebPageTest adds a specific string to the user-agent of any browser used in its tests. Since MachMetrics (as well as many other synthetic speed monitors) use WebPageTest under the hood, you can easily filter out any of these sessions. Simply look for the phrase ‘PTST‘ in the user agent string.
Here’s a recent example:
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36 PTST/402
How to filter from Google Analytics
Most analytics services allow you to filter by user-agent, in which case you can use the filter ‘PTST’ above, but Google Analytics is different (of course). Google Analytics allows you to exclude traffic from specific hosts, ip addresses, or in specific directories. That doesn’t help us.
Fortunately they do offer another way to filter out traffic from synthetic testing bots, in the ‘View Settings’ option under your Google Analytics Admin area. Check the ‘Exclude all hits from known bots and spiders’ under Bot Filtering.
Simply check that box, hit save, and from that point forward most bots, including those from WebPageTest and MachMetrics will be filtered out.
Here’s a screenshot showing the change in my visitor/sessions graph a couple weeks after this change was made. You can clearly see the filtering started on April 18th:
It’s important to note that this filter doesn’t take effect retroactively – all previously recorded bot traffic will still show up in your stats. But any future visits will be excluded.