Tracking despite an Ad Blocker: Mixpanel through proxy

I debated with myself on whether or not to share this. As a user I don't like tracking and block it when I can. But a new startup needs to understand what their users are doing and big companies surely have workarounds in place already...  So here goes.

First - here's the problem and a vague allusion to the solution:

Ad Blockers Affect Mixpanel
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 ...

Okay, here's the code I had before the fix - this reaches out to Mixpanel directly and is therefore blocked by many Ad Blockers.


So I add in the proxy and tell Mixpanel to ignore the IP address of my proxy server (otherwise all my users would have the same IP Address).

const proxy_url = '';

mixpanel.init(mixpanel_token, { api_host: `${proxy_url}`, ip: 0 });

But there's one more piece we need to add! The actual IP address! This help page suggests you can pass the IP address so I figured I'd give it a shot.

Fetch the user's IP address (not shown) and register it so it's passed with every Mixpanel call within this session.

      ip: ip,

Don't be creepy with this. Only use tracking to improve your platform, not to exploit users!