Setting up a proxy using Nginx
Optimize tracking by proxying data via Nginx.
NGINX is a popular web server and reverse proxy. If you’re using NGINX to serve your website, we’ve prepared this guide to help you proxy the traffic through your own domain.
Setup
NGINX Configuration
Below you can see an example config for proxying the Vemetric Script and Hub. Please make sure to adjust the config according to your needs (like adding SSL certificates). At least you need to adjust the server_name to your desired domain.
We recommend avoiding names or paths like
analytics.yourdomain.comoryourdomain.com/track, as this might also trigger ad/tracker blockers.Use more generic names like
hub.yourdomain.cominstead.
Configure Vemetric
Depending on your setup you need to adjust the Vemetric configuration:
The src attribute of the script tag should now point to https://hub.yourdomain.com/main.js. You also need to pass the data-host attribute with the value of https://hub.yourdomain.com
For the JavaScript SDK, you need to pass the scriptUrl and host options to the init function with the value of your proxy domain.
For the React SDK, you need to pass the scriptUrl and host props to the VemetricScript component with the value of your proxy domain.
For the Astro SDK, you need to pass the scriptUrl and host props to the VemetricScript component with the value of your proxy domain.
Congratulations! You’ve successfully set up a proxy using NGINX. Please reach out if you have any questions.
Optimize tracking by proxying data via Vercel.
Optimize tracking by proxying data via Cloudflare.