Ad Blockers Affect Mixpanel - Articles From the Archive

  • 29 July 2019
  • 1 reply

Userlevel 6
Badge +4

Each week, Mixpanel will release articles from our archives to help you get the most out of Mixpanel. Follow the Topic Tag #fromthearchive to subscribe to these posts and get alerted when they drop.

Depending on your website and the type of ad blocker, some users who have ad blockers enabled can prevent Mixpanel from loading on your page.

As a result, Mixpanel will not be able to collect data from those users.

Consider the following for users that Mixpanel does not track because of ad blockers:

  1. Generally, only a small percent of users have ad blockers enabled that prevent Mixpanel from tracking actions. Depending on the nature of your site, decide if not tracking users who have ad blockers enabled is acceptable.
  2. If you have some critical events (e.g., account creation, successful purchase, and so on) that you need tracked, you can track those critical events server-side. That way, you can capture those actions even for users with ad blockers. If you chose this route, make sure you’re properly handling identity management for a hybrid implementation.
  3. If your particular site a larger percentage of users have ad blockers enabled, or if all events are critical, you may consider an entirely server-side implementation (Python, Java, PHP, Ruby).
  4. You can use the JavaScript client-side SDK to proxy the calls to your own server first. Ad blockers block all outgoing calls made to a different domain than the current one, so your api_host will need to be on the same domain as your site.
    You can set the api_host config option to your own server when initializing Mixpanel, not necessarily within each track call:
mixpanel.init("YOUR TOKEN", { api_host: "" });

The data is sent to your proxy first and then you can relay to Mixpanel. Since Mixpanel by default grabs the IP of the proxy server, you'll need to take the IP of the request, include it as a property in the event, and set ip=0 at the header of the request itself.

1 reply

Hi Stephanie,


On point#4 above, can you please elaborate more on this. My requirement is something like this:

  • Instead of sending the tracking details directly to the MixPanel portal, I want a solution which can send them to a proxy-server first and then proxy-server can relay the information to MixPanel. I am thinking to use MixPanel JS SDK.

I think, setting api_host property in mixpanel.init() should do the job but I have few doubts:

  • About the implementation on the proxy-server side (to swallow the tracking requests and to relay the information to MixPanel) ?
  • About the mixpanel.track() calls?  These calls will be unchanged or we need to tweak them a little bit?

Appreciate your comments. Thanks.


BR, Abhishek