Content management systems
Add Loogika to Contentful
Contentful is a headless CMS (content management system). Its job is to hold your content and hand it out through APIs, and it never builds your pages. The Loogika tag therefore goes into the frontend that reads from Contentful, not into Contentful itself.
Last updated .
What do you need before you start?
Copy your script tag from Site Settings in Loogika, under the Tracking Script tab. It looks like this, with your own site ID in place of YOUR_SITE_ID:
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
You also need access to the code of the website or app that fetches content from Contentful.
Where does the Loogika tag go on a Contentful site?
The tag goes into the <head> of your frontend application. Contentful has no template and no header setting where you can paste code. Follow the guide for the framework your frontend uses:
- Next.js. Load the script with
next/scriptin the root layout, so every route gets it. - Nuxt. The script goes into
nuxt.config.ts, underapp.head.script. - Gatsby, together with
gatsby-source-contentful, the official plugin. - Remix
- React with Vite
- Vue with Vite
- Astro
- SvelteKit
- Angular
How do you check that Loogika is installed?
Open the live frontend in another tab and visit a few pages. The pageviews show up in the Loogika dashboard within a few seconds.
If the dashboard stays empty, open the page source and look for script.js?siteId=. A missing tag means the layout you edited is not the one your pages use, or the new build is not deployed yet.
Do Contentful previews count as visits?
Yes, when the preview build carries the tag. A content preview URL in Contentful leads to a draft or preview build of your frontend, and that build runs the same code as the live site.
You can keep editors out of your production numbers in two ways. Either register the preview deployment in Loogika as a separate site, or build previews without the tag.
Does Loogika track the Contentful web app?
No. The tag runs only on your frontend, so the time editors spend inside Contentful never shows up in Loogika.