Proxy DataFast with Express.js
Learn how to proxy DataFast analytics through your Express.js server to bypass adblockers and improve accuracy.
1. Install Required Dependencies
npm install express-http-proxy
2. Add Proxy Configuration
Add the following to your Express.js application:
const express = require('express');
const proxy = require('express-http-proxy');
const app = express();
// Proxy the script
app.use('/js/script.js', proxy('datafa.st', {
proxyReqPathResolver: function (req) {
return '/js/script.js';
}
}));
// Proxy the events endpoint
app.use('/api/events', proxy('datafa.st', {
proxyReqPathResolver: function (req) {
return '/api/events';
}
}));
// Your other routes...
app.listen(3000);
3. Update Your Script Tag
Replace your existing DataFast script with the proxied version:
<script
defer
data-website-id="yourwebsiteid"
data-domain="yourdomain.com"
src="/js/script.js"
></script>
4. Deploy your server
The proxy configuration will take effect automatically after deployment.
Verification
To verify the proxy is working:
- Visit your website
- Open the network tab in your browser's developer tools
- Check that analytics requests are going through your domain instead of datafa.st