Getting rid of GTM host events in Mixpanel

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.

mixpanel gtm

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 , so the best thing to do is to block events from domain / host

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 ('') == -1) {



Above, code will check if the document location and on the mismatch with it would execute the Mixpanel event. Thus filtering out all the GTM generated events.

Read more