Documentation tools
Add Loogika to Mintlify
You add Loogika to Mintlify with a small JavaScript file in your docs content directory. Mintlify includes every .js file from that directory on every page. The file creates the Loogika script tag and adds it to the head of the page.
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 12-character site ID in place of YOUR_SITE_ID:
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
Mintlify takes JavaScript files and not HTML tags. You therefore use the address from the src attribute in the file below.
How do you add the Loogika script to Mintlify?
Create a file named loogika.js in your content directory. That is the folder that holds docs.json and your .mdx pages.
(function () {
var el = document.createElement("script");
el.src = "https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID";
el.defer = true;
document.head.appendChild(el);
})();
Commit the file and deploy. Mintlify picks the file up by itself, and you register nothing in docs.json. Mintlify describes the current rules for file placement on the custom scripts page of its own documentation.
How do you set script options such as skip patterns?
Set the attribute on the element before you append it to the head. This version keeps every page under /internal/ out of your reports with data-skip-patterns:
(function () {
var el = document.createElement("script");
el.src = "https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID";
el.defer = true;
el.setAttribute("data-skip-patterns", JSON.stringify(["/internal/**"]));
document.head.appendChild(el);
})();
The other attributes work the same way. The tracking script page lists them with their defaults.
Does Loogika count page changes in Mintlify?
Yes. A Mintlify site is a single-page app, which means the address changes without a full page load. Loogika records each route change as a pageview when SPA Navigation is on in Site Settings. The setting is on for a new site.
How do you track a custom event in Mintlify?
A Mintlify page is written in MDX, which lets you put a click handler straight on an element in the page. This button sends the event download_clicked with the file name as a property:
<button
onClick={() => window.loogika?.event("download_clicked", { file: "getting-started.pdf" })}
>
Download guide
</button>
The events page explains event names, properties and their limits.
How do you check that Loogika is installed?
Load your deployed docs in a fresh browser tab and visit a few pages. The pageviews show up in the Loogika dashboard within a few seconds.
If nothing arrives, open the Network tab of your browser and reload. A working install loads script.js with status 200 and then sends requests to /api/track. The script troubleshooting page covers ad blockers and other causes.