Reputation: 642
I configured GTM to load Mixpanel on every page on my domain and added click tracking on buttons like described on this blog: https://mixpanel.com/blog/2015/03/27/community-tip-implementing-mixpanel-via-google-tag-manager
This is not deployed to any server yet, just localhost, but it seems whenever clicks are being tracked, I get bogus events in mixpanel coming from the US on this url: https://gtm-msr.appspot.com/render2?id=GTM-XXXXX
with this user agent: Mozilla/5.0 (Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; EIE10;ENUSWOL; rv:11.0) like Gecko
Anyone encountered this before? Any idea's what is happening here?
Upvotes: 4
Views: 4007
Reputation: 1853
This seems to happen whenever Google Tag Manager configurations are changed, possibly somewhere in the build process it's tested on an environment from the .appspot
domain.
This can be rectified by only initializing mixpanel on non-offending domains:
if (document.location.href.search('.appspot.') == -1)
mixpanel.init(YOUR_TOKEN);
Upvotes: 1
Reputation: 657
I'm having the same issue and was thinking of checking where the page load was coming from before executing the code. This may be more convenient (doesn't depend on the user agent):
<script type="text/javascript">
if (document.location.href.search('.appspot.') == -1) {
/* run your code */
}
</script>
What you search for could be tweaked, but the odds this part of the URL will change is much less likely than the user agent.
Upvotes: 0
Reputation: 642
As a workaround I added a check in the mixpanel tracking code in GTM to filter out the bogus user agent. Of course, this works for now, until they change the user agent.
<script type="text/javascript">
if (navigator.userAgent != 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; EIE10;ENUSWOL; rv:11.0) like Gecko') {
var pagePath = {{Page Path}};
mixpanel.track("Page Loaded", {"Page Path": pagePath, "User Agent": navigator.userAgent});
}
</script>
Adding a filter in GTM itself doesn't work either, GTM ignores it.
Upvotes: 0