Tracking Script Configuration
Advanced configuration options for the Invoker Analytics tracking script.
Script Variants
We offer different script variants for specific use cases:
| Script | Size | Features |
|---|---|---|
script.js | <1KB | Standard tracking, events, goals |
script.outbound.js | ~1.2KB | + Automatic outbound link tracking |
script.file-downloads.js | ~1.2KB | + Automatic file download tracking |
script.hash.js | ~1KB | + Hash-based routing support |
Page Exclusion
Exclude specific pages from tracking using the data-exclude attribute:
<!-- Exclude specific pages --> <script defer data-domain="yourdomain.com" data-exclude="/admin/*, /private/*" src="https://cdn.invoker.app/js/script.js"></script>
Exclusion patterns support wildcards:
/admin/*- Exclude all pages starting with /admin/*/private/*- Exclude any URL containing /private//exact-page- Exclude only this exact page
Page Inclusion
Track only specific pages using the data-include attribute:
<!-- Only track specific pages --> <script defer data-domain="yourdomain.com" data-include="/blog/*, /products/*" src="https://cdn.invoker.app/js/script.js"></script>
Custom API Endpoint
If you're using a custom domain or proxy for the API:
<script defer data-domain="yourdomain.com" data-api="https://your-proxy.com/api/event" src="https://cdn.invoker.app/js/script.js"></script>
SPA Mode
Enable automatic pageview tracking for single-page applications:
<script defer data-domain="yourdomain.com" data-spa="true" src="https://cdn.invoker.app/js/script.js"></script>
When SPA mode is enabled, the script automatically:
- Listens for
popstateevents (browser back/forward) - Monitors
pushStateandreplaceStatecalls - Tracks pageviews when the URL changes
Self-Hosting the Script
You can self-host the tracking script if needed:
- Download the script from
https://cdn.invoker.app/js/script.js - Host it on your own server or CDN
- Update the
srcattribute to point to your hosted version - Set the
data-apiattribute to use our API or your proxy
<script defer data-domain="yourdomain.com" data-api="https://api.invoker.app/api/event" src="/js/invoker.js"></script>
Proxy Setup
To avoid ad-blockers, you can proxy API requests through your own domain:
Nginx Configuration
location /api/event {
proxy_pass https://api.invoker.app/api/event;
proxy_set_header Host api.invoker.app;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}Vercel/Next.js Rewrites
// next.config.js
module.exports = {
async rewrites() {
return [
{
source: '/api/event',
destination: 'https://api.invoker.app/api/event',
},
{
source: '/js/script.js',
destination: 'https://cdn.invoker.app/js/script.js',
},
];
},
};Testing Your Installation
To verify the script is working correctly:
- Open your browser's developer tools (F12)
- Go to the Network tab
- Load your page
- Look for a request to
/api/event - The response should be
{"status":"ok"}
You can also check in your Invoker dashboard - data should appear within a few seconds in the Real-time analytics section.
Troubleshooting
- Check if the script URL is correct
- Verify no ad-blocker is blocking the request
- Check browser console for errors
- Verify
data-domainmatches your site in Invoker - Check that the domain includes any subdomains correctly
- Ensure your site is using HTTPS
- Check you haven't added the script twice
- If using SPA mode, don't also call
trackPageview()manually - Verify no other analytics integrations are interfering