Getting rid of GTM host events in Mixpanel
Anyone who have played around with Mixpanel implementation with GTM would have seen BOTs triggering events like below.
To solve the issue, we would just need some JavaScript code. But let’s see the logic before discussing that, you will notice that the Current URL of GTM generated events will be always on domain gtm-msr.appspot.com , so the best thing to do is to block events from domain / host appspot.com.
For this, we will enclose the GTM MIXPANEL EVENT CUSTOM HTML tag in a JavaScript if statement which will check the host of the domain and execute the code.
<script type="text/javascript"> if (document.location.href.search('appspot.com') == -1) { //MIXPANEL EVENT } </script>
Above, code will check if the document location and on the mismatch with appspot.com it would execute the Mixpanel event. Thus filtering out all the GTM generated events.