Or does it also track dev? If it tracks dev is there a solution that only works in prod?
Not sure which plugin you are using but generally the Google Analytics plugins (and others) have options for a Live and Test Google analytics measurement ID.- with Test being optional.
So you two measurement IDs, one for Live, one for test. This is what I have found to be best practice, rather than creating filters on the GA side of things.
I wasnt using a plugin. FIlled in the script/meta section in SEO/metatags settings.