Invoker Analytics/Documentation
Developers

Tracking Script Configuration

Advanced configuration options for the Invoker Analytics tracking script.

Script Variants

We offer different script variants for specific use cases:

ScriptSizeFeatures
script.js<1KBStandard 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 popstate events (browser back/forward)
  • Monitors pushState and replaceState calls
  • Tracks pageviews when the URL changes

Self-Hosting the Script

You can self-host the tracking script if needed:

  1. Download the script from https://cdn.invoker.app/js/script.js
  2. Host it on your own server or CDN
  3. Update the src attribute to point to your hosted version
  4. Set the data-api attribute 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:

  1. Open your browser's developer tools (F12)
  2. Go to the Network tab
  3. Load your page
  4. Look for a request to /api/event
  5. 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

Script not loading?
  • Check if the script URL is correct
  • Verify no ad-blocker is blocking the request
  • Check browser console for errors
No data appearing?
  • Verify data-domain matches your site in Invoker
  • Check that the domain includes any subdomains correctly
  • Ensure your site is using HTTPS
Duplicate pageviews?
  • 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