DataSag guides · Updated 27 October 2026
Load analytics without blocking rendering on Docusaurus
Use the platform's non-blocking external script mechanism and install the tracker once. Measure the published page before and after the change; script size alone cannot predict the effect on your website. This guide applies to Docusaurus.
Start with the Docusaurus installation
Add an object to the existing Docusaurus scripts array with src, defer and data-datasag-key attributes. Preserve the rest of your configuration. Build and serve the generated production site, then test a documentation route directly and through client navigation. The config runs in Node.js, so browser event calls do not belong there.
Docusaurus accepts string script entries, but an object is needed here to preserve the public tracking-key attribute and explicit non-blocking loading. Do not also insert the tracker through a client module, swizzled theme component or individual MDX page.
Use the public project key from the DataSag project you are inspecting. A test on a preview domain does not confirm that the production domain has the same code or settings.
Load analytics without blocking rendering in Docusaurus
- Use the object form in scripts so defer is explicit. A string entry can create a blocking external script. Preserve the required data attribute while changing loading behavior, rather than replacing the object with its URL.
- Measure generated production docs with the same sidebar state, content and cache conditions. Inspect tracker timing beside Docusaurus assets, then verify the first intended interaction occurs after tracking becomes available.
- Test an internal sidebar transition after the first load. The existing installation should handle path changes without another loader. If you move loading to a later client module, document the short visits or early actions it can miss.
Non-blocking configuration is verified on production output with both startup timing and client-navigation coverage measured.
Complete the collection checks
- Record a baseline of the published page using the same browser, device emulation and network settings you will use for comparison. Include a representative content page, not only the homepage.
- Use defer for a normal external HTML script, or the framework-specific loading strategy shown in the installation example. Do not add a parser-blocking synchronous script as a shortcut.
- Keep one installation in the shared document or layout. Duplicate execution adds work even if the browser reuses the downloaded file.
- Inspect the Network waterfall for tracker.js and /api/track. Compare transfer size, timing and request count on a cold load and a cached load.
- Check that measurement still starts at the intended point. Loading only after idle or interaction can omit short visits and early clicks; performance and coverage must be evaluated together.
- Repeat the measurements and record variability. Report measured results for your page rather than claiming a universal speed improvement or zero performance cost.
// Browser Console, after loading the published page:
performance.getEntriesByType('resource')
.filter(entry => entry.name.includes('/tracker.js'))
.map(entry => ({ url: entry.name, durationMs: entry.duration }));
// Cross-origin transfer details may be unavailable.What a successful check looks like
The script uses a non-blocking loading mechanism, appears once and records the intended visits. Any performance claim comes from repeatable measurements of the actual site.
Record the public path you tested, the browser state, the approximate time and the observed request. Check one direct page load and one later navigation so the result covers more than the homepage.
Common mistake
A faster lab result does not prove every visitor has a faster experience. Avoid mixing a warm-cache result with a cold-load baseline.
Installation snippet for Docusaurus
The shared installation belongs in the scripts array in docusaurus.config.js or docusaurus.config.ts. Use this as the installation reference while checking the procedure above.
// Merge this entry into the existing scripts array.
export default {
scripts: [{
src: "https://www.datasag.com/tracker.js",
defer: true,
"data-datasag-key": "YOUR_PUBLIC_KEY"
}]
};Related Docusaurus guides
References
Official Docusaurus documentation covers the integration point. For DataSag data handling, read the privacy policy. Use support if a request fails after these checks.