One of the problems with the solution above is that it is difficult to edit the hosts file on mobile devices.
Here is another workaround:
Create a βsecretβ HTML file called x.html (or something else) that sets up a special cookie and uploads it to your website.
<html> <head> <title>mixpanel cookie</title> <script type="text/javascript"> document.cookie = "analytics-ignore=true; max-age=31536000; path=/"; </script> </head> <body> setting cookie. </body>
in your website / application, check this cookie before starting the mixpanel script initiation.
if (document.cookie.indexOf ('analytics-ignore') === -1) {//...mixpanel code ...}
Note that you can check for the presence of the mixpanel variable before calling your methods ( mixpanel.track ).
Just go to the x.html page once (well, once a year, for the browser and after clearing your cookies, etc.)
source share