Wow. I didn't expect it to be so complicated. I thought there is a dedicated function to hide viewlets within a given context I was not aware of.
Ehm.......... Not to troll, but this sounds a bit like "if there isn't already a switch or field that implements the exact extra functionality I require, it is complicated".
This is both a user,integrator and developer forum so you will get different kinds of suggestions on different levels. If it's not already in "Plone the product" you will have to do some modifications in "Plone the framework".
Viewlets are the lower level workhorses of small code/template snippets, they have no 'user' exposed controls except for the deveoper oriented @@manage-viewlets. Portlets (loved and despised) are editor friendly 'super viewlets with local data' with lots of UI that you can configure.
To control viewlets like the analytics viewlet from inside Plone you will have to do a bit of Python programming to enable/disable them and with Python you have full low level control over the inputs like context, request, whatever.
If your 5.2 website has a Diazo Theme then you can avoid messing with the interna of the CMS as Diazo is working at the end of the pipeline on the generated html from the App Server just before it is delivered to the browser.
But Diazo has only been part of Core Plone since Plone 5, It was optional in Plone 4.
In the Diazo rules you could add a:
The tricky part with Diazo rules is that you have to account for the order they are executed from the rules.xml in your Diazo theme. 'drop' is executed early in the process and one of the default rules in most themes is to copy the whole footer from content to theme and you can only copy one subtree of html once. See https://docs.diazo.org.
You could drop the analytics html for certain paths from the content, or alternatively you remove the html with the css:selector from the theme's index.html . It's difficult to give advice as I have no clue if you use default Barceloneta or a custom theme and how it is set up.