Skip to content

Installing the Tracking Script

import { Aside, Steps, Tabs, TabItem } from ‘@astrojs/starlight/components’;

This guide covers all installation options for analyze.swiss, from basic script tags to advanced framework integrations.

The simplest way to install analyze.swiss is with a script tag:

<script
src="https://analyze-ingest.thismatters.workers.dev/s/a.js"
data-api-key="YOUR_API_KEY"
data-auto-capture="true"
defer>
</script>

Place this in your <head> section, ideally just before </head>.

AttributeRequiredDefaultDescription
data-api-key✅ YesYour workspace API key
data-auto-captureNotrueEnable automatic event capture
data-track-localhostNofalseTrack events on localhost
data-cross-domainNoComma-separated domains for cross-domain tracking
data-mask-inputsNotrueMask sensitive input values
data-respect-dntNotrueRespect Do Not Track header
<script
src="https://analyze-ingest.thismatters.workers.dev/s/a.js"
data-api-key="pk_live_xxxxx"
data-auto-capture="true"
defer>
</script>
Terminal window
npm install @analyze.swiss/sdk
import { Analyze } from '@analyze.swiss/sdk';
const analyze = new Analyze({
apiKey: 'pk_live_xxxxx',
autoCapture: true
});
  1. Create a new Custom HTML tag
  2. Paste the script code:
    <script
    src="https://analyze-ingest.thismatters.workers.dev/s/a.js"
    data-api-key="YOUR_API_KEY"
    data-auto-capture="true">
    </script>
  3. Set the trigger to All Pages
  4. Save and publish
app/layout.tsx
import Script from 'next/script';
export default function RootLayout({ children }) {
return (
<html>
<head>
<Script
src="https://analyze-ingest.thismatters.workers.dev/s/a.js"
data-api-key="YOUR_API_KEY"
data-auto-capture="true"
strategy="afterInteractive"
/>
</head>
<body>{children}</body>
</html>
);
}
pages/_app.tsx
import Script from 'next/script';
export default function App({ Component, pageProps }) {
return (
<>
<Script
src="https://analyze-ingest.thismatters.workers.dev/s/a.js"
data-api-key="YOUR_API_KEY"
data-auto-capture="true"
strategy="afterInteractive"
/>
<Component {...pageProps} />
</>
);
}
// src/index.tsx or src/main.tsx
import { useEffect } from 'react';
function App() {
useEffect(() => {
const script = document.createElement('script');
script.src = 'https://analyze-ingest.thismatters.workers.dev/s/a.js';
script.dataset.apiKey = 'YOUR_API_KEY';
script.dataset.autoCapture = 'true';
script.defer = true;
document.head.appendChild(script);
}, []);
return <YourApp />;
}

Or use our React SDK:

Terminal window
npm install @analyze.swiss/react
import { AnalyzeProvider } from '@analyze.swiss/react';
function App() {
return (
<AnalyzeProvider apiKey="YOUR_API_KEY">
<YourApp />
</AnalyzeProvider>
);
}
App.vue
<script setup>
import { onMounted } from 'vue';
onMounted(() => {
const script = document.createElement('script');
script.src = 'https://analyze-ingest.thismatters.workers.dev/s/a.js';
script.dataset.apiKey = 'YOUR_API_KEY';
script.dataset.autoCapture = 'true';
script.defer = true;
document.head.appendChild(script);
});
</script>
nuxt.config.ts
export default defineNuxtConfig({
app: {
head: {
script: [
{
src: 'https://analyze-ingest.thismatters.workers.dev/s/a.js',
'data-api-key': 'YOUR_API_KEY',
'data-auto-capture': 'true',
defer: true
}
]
}
}
});
src/layouts/Layout.astro
<html>
<head>
<script
src="https://analyze-ingest.thismatters.workers.dev/s/a.js"
data-api-key="YOUR_API_KEY"
data-auto-capture="true"
defer>
</script>
</head>
<body>
<slot />
</body>
</html>

Add to your theme’s functions.php:

function add_analyze_swiss_script() {
?>
<script
src="https://analyze-ingest.thismatters.workers.dev/s/a.js"
data-api-key="YOUR_API_KEY"
data-auto-capture="true"
defer>
</script>
<?php
}
add_action('wp_head', 'add_analyze_swiss_script');

Add to your theme’s theme.liquid:

<!-- In the <head> section -->
<script
src="https://analyze-ingest.thismatters.workers.dev/s/a.js"
data-api-key="YOUR_API_KEY"
data-auto-capture="true"
defer>
</script>

After adding the script:

  1. Open your website in a browser
  2. Open Developer Tools (F12)
  3. Go to the Network tab
  4. Look for requests to analyze-ingest.thismatters.workers.dev
  5. Check your analyze.swiss dashboard for incoming data
  • Check if an ad blocker is blocking the request
  • Verify the API key is correct
  • Ensure the script tag is properly formatted
  • Wait up to 30 seconds for data to appear
  • Check browser console for errors
  • Verify data-track-localhost="true" if testing locally

Our script handles CORS automatically. If you see CORS errors:

  • Clear your browser cache
  • Try in an incognito window
  • Contact support if the issue persists