Nginx proxy
Proxy the attribu.tech script and API through Nginx.
This is a server-specific guide. See Proxy the tracking script for an overview of why and how proxying works.
Nginx configuration
Add these location blocks inside your server block:
# Proxy the attribu.tech tracking script
location /js/attribu.js {
proxy_pass https://attribu.tech/js/script.js;
proxy_set_header Host attribu.tech;
proxy_ssl_server_name on;
}
# Proxy the attribu.tech event API
location /api/proxy/events {
proxy_pass https://attribu.tech/api/events;
proxy_set_header Host attribu.tech;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_ssl_server_name on;
}Reload Nginx after saving the config:
sudo nginx -t && sudo systemctl reload nginxUpdate your script tag
Point the script src to your proxied path and set data-api-url to your proxied API endpoint:
<script
defer
data-website-id="YOUR_SITE_ID"
data-domain="yourdomain.com"
data-api-url="https://yourdomain.com/api/proxy/events"
src="/js/attribu.js"
></script>Replace
YOUR_SITE_ID with your actual Website ID from attribu.tech. Replace yourdomain.com with your website's root domain.Verify installation
- Visit your site in an incognito/private window.
- Open your browser's Developer Tools and go to the Network tab.
- Confirm the script loads from
/js/attribu.json your domain. - Confirm the pageview POST goes to
/api/proxy/eventson your domain. - Check your attribu.tech dashboard. A new pageview should appear within a few seconds.
What's next
- Back to proxy overview
- Caddy proxy setup
- Connect Stripe to attribute revenue to traffic sources.