amplitude is not working when adblocker is enabled

  • 11 April 2022
  • 4 replies

Userlevel 2
Badge +1

i am getting this error in console ..



also i am able to send events to dashboard since the. ad-blocker extension is enabled, how do i make amplitude work when ad-blocker is enabled ? 


Best answer by Zhenia Semenina 12 April 2022, 17:41

View original

4 replies

Userlevel 4
Badge +7

Hey there,

Happy to help!

We do not offer official support for circumventing ad-blockers but the easiest way to go around Ad-Blockers is by running a reverse proxy through your own domain. - Please note that it is best that this process is done by an Engineer or a Developer as this is a technical workaround.

What is a Reverse Proxy Server?

A Reverse Proxy Server is a server that sits in front of a web server and forwards HTTP requests to that web server. Some examples of popular servers that include Reverse Proxys are: NGINX, Apache, and Squid. Theoretically, you can also do this forwarding with any application server by creating a route that forwards all request headers and the body to Amplitude. In practice, the way this would work is by you running a web server on your domain that forwards all analytics requests from a path on your domain to Amplitude’s event endpoint.

How does it work?

There are two parts of this process: setting up the Reverse Proxy and then configuring Amplitude to use that server as a data source. The Proxy we are going to use is NGINX, a popular web server, and load balancer that also has the ability to function as a reverse proxy:

1. Installing NGINX - you can typically use homebrew or apt-get to do the actual installation. For example brew install nginwould work if you are running a Mac OS.


2. Configuring NGINX - here you will have to configure NGINX to proxy requests on a particular URL to Amplitude. Please see the below sample of a nginx.conf file that will accomplish that:

worker_processes 1;error_log logs/error.log;error_log logs/error.log notice;error_log logs/error.log info;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 8080; server_name localhost; location /analytics/ { proxy_pass; } }}

3. Starting and Testing the Proxy - once you have finished setting up the configuration file, you should be able to start and test your Proxy.


4. Configuring Amplitude - this is the final step of the process, where you will need to configure Amplitude to send requests to NGINX:

HTTP API Configuration: If you are using our HTTP API all you have to do is send the requests to your endpoint rather than to ours. Please do note that the HTTP API uses a slightly different endpoint from our SDKs, so to test, you will need to temporarily set proxy_pass to .

If the Reverse Proxy setup was done correctly, then using the above command should return a 200 response code. In Amplitude, you can use the User Lookup functionality to check if the event was sent successfully.

JS SDK Configuration: Amplitude’s JS SDK provides multiple options that allow events to be sent to an alternative server endpoint. If you are using our JS SDK you can set the apiEndpoint option when initializing the SDK.

Android SDK and iOS SDK Configuration: here you can use setServerUrl to configure the server URL. Once you this is done you should be able to send events through your proxy and see them logged in Amplitude.

Hope this helps and please let me know if you need help with anything else.

We've got some great information on this here: 

Hope this helps! 

Userlevel 2
Badge +1

@Zhenia Semenina  Thanks for detailed guide but do you similar guide for Apache setup we use apache 

Userlevel 2
Badge +1

@Zhenia Semenina  if you have similar guide for apache setup please share..

Userlevel 6
Badge +9

Hi @pawan, Thanks for following up. I’m Jeremie the community manager. Were you able to make progress here? Please let me know if you need any additional support. 😀