OnyxMetric
Integration Guides

Contentful

Add OnyxMetric analytics to a site that uses Contentful

Contentful is a headless CMS. It stores content and serves it over an API, while your own frontend renders the pages. The tracking tag therefore belongs in that frontend, not in Contentful.

Copy your tracking snippet

In OnyxMetric, open your site's Site Settings and copy the tracking script. It looks like this:

<script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>

YOUR_SITE_ID is the numeric ID of your site.

Add the snippet to Contentful

Contentful has no template or head setting to paste into. Add the snippet to the <head> of the frontend app that fetches content from Contentful.

Load the script with next/script in your root layout so it runs on every route. Follow the Next.js guide.

Add the script under app.head.script in nuxt.config.ts. Follow the Nuxt guide.

Client-side route changes are tracked automatically, so moving between pages in any of these frameworks is counted without extra code.

Check that it works

Load your live site and click through a few pages. Pageviews show up in the OnyxMetric dashboard within seconds.

If nothing arrives:

  • View the page source and search for script.js?siteId= to confirm the tag is present.
  • In the browser's Network tab, check that script.js returns 200 and that requests go to /api/track.
  • Turn off ad blockers, or proxy the script through your own domain.
  • Read script troubleshooting for other causes.

Troubleshooting

  • Preview deployments: if you run a separate preview site for editors, register it as its own site in OnyxMetric so draft traffic stays out of your real numbers.
  • The Contentful web app is not tracked: the tag only runs on your frontend, so time editors spend in Contentful never shows up.

Next steps

On this page