It depends on how sophisticated the bots that you’re dealing with are. It’s super easy for a bot to change their user agent string. If, however, all the bots do identify themselves politely via the UAS, the solution that you’ve proposed will help ignore their traffic in analytics.