Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

netlify proxying docs

Blue Mouse8258045d3961
diff --git a/docs/adblockers/guides/netlify.md b/docs/adblockers/guides/netlify.md
new file mode 100644
index 000000000..b1ed7f563
--- /dev/null
+++ b/docs/adblockers/guides/netlify.md
@@ -0,0 +1,32 @@
+---
+title: How to proxy Swetrix with Netlify
+slug: /adblockers/guides/netlify
+---
+
+You can use [Netlify redirects](https://docs.netlify.com/routing/redirects/) to proxy Swetrix analytics traffic via your domain.
+
+## Setup Netlify rewrites rules
+First, you need to add the following rules to the `_redirects` file. If you don't already have it, you will need to [create it](https://docs.netlify.com/routing/redirects/rewrites-proxies/) first.
+```
+/script.js https://swetrix.org/swetrix.js 200
+/sproxy https://api.swetrix.com/log 200
+```
+
+Instead of `/script.js` and `/sproxy` routes, you can use any other name. We recommend using a generic name or even just random letters to avoid being blocked by adblockers in the future.
+
+:::note
+Make sure you don't use `/log`, `/analytics`, `/analytics.js` or any similar name, because they're blocked by many adblockers by default.
+:::
+
+## Update Swetrix tracking script configuration
+After you set up Netlify redirect rules, you need to update swetrix.js tracking script to send analytics data through it. You can do it by setting the `apiURL` property inside the [init() function](/swetrix-js-reference#init).
+
+```javascript
+swetrix.init('YOUR_PROJECT_ID', {
+ apiURL: 'https://<yourproxydomain>/sproxy',
+})
+```
+
+:::note
+If you are not using the [Swetrix NPM package](/install-script#install-swetrix-via-npm), don't forget to also replace `https://swetrix.org/swetrix.js` with your proxy URL in the analytics `<script>` tag.
+:::
diff --git a/docs/adblockers/guides/nginx.md b/docs/adblockers/guides/nginx.md
index 8211d035f..5dfe90ef3 100644
--- a/docs/adblockers/guides/nginx.md
+++ b/docs/adblockers/guides/nginx.md
@@ -57,3 +57,7 @@ swetrix.init('YOUR_PROJECT_ID', {
apiURL: 'https://<yourproxydomain>/log',
})
```
+
+:::note
+If you are not using the [Swetrix NPM package](/install-script#install-swetrix-via-npm), don't forget to also replace `https://swetrix.org/swetrix.js` with your proxy URL in the analytics `<script>` tag.
+:::
diff --git a/docs/adblockers/how-to-deal-with-adblockers.md b/docs/adblockers/how-to-deal-with-adblockers.md
index 0fcd83de4..c1ac2a4b5 100644
--- a/docs/adblockers/how-to-deal-with-adblockers.md
+++ b/docs/adblockers/how-to-deal-with-adblockers.md
@@ -24,4 +24,5 @@ If you've installed [Swetrix using npm](/install-script#install-swetrix-via-npm)
If you have installed Swetrix using our CDN (`swetrix.org/swetrix.js`), you will need to proxy it to bypass adblockers. Please refer to one of the guides below on how to do this.
### Managed proxy guides
+ - [Netlify](/adblockers/guides/netlify)
- [Nginx](/adblockers/guides/nginx)
diff --git a/sidebars.js b/sidebars.js
index 9ae09bea5..2d9c5c093 100644
--- a/sidebars.js
+++ b/sidebars.js
@@ -45,6 +45,11 @@ module.exports = {
type: 'doc',
label: 'Nginx',
},
+ {
+ id: 'adblockers/guides/netlify',
+ type: 'doc',
+ label: 'Netlify',
+ },
],
},
],