Documentation
Plain HTML script guide
In Add website or Settings, copy the script snippet with your real Site ID and tracking origin. Paste it once in the shared head of every public page:
<script defer data-website-id="YOUR_SITE_ID" src="https://YOUR_ANALYTICS_HOST/js/script.js"></script>
Publish and open your public domain, then click Verify installation. Do not also initialize the npm package or a plugin on that page. The tracker sends the initial pageview, handles SPA navigation, engagement and outbound clicks. Permit the analytics origin in CSP script-src and connect-src.
Consent and private pages
If your site has a cookie banner, do not wait for consent to load the script, or visitors who ignore the banner are never counted. Add data-consent="pending" and call window.analyticfast?.('consent', true) when the visitor accepts. See Cookie banners and consent.
To keep the tracker off a page entirely, append the script only when your policy allows it. For a dynamic loader, the script element may expose an optional synchronous afxEnabled() function returning whether analytics is allowed now. Set it before appending the script. The tracker checks it before cookies, new requests, link decoration and deferred identity requests; a thrown error denies tracking. This also lets your site exclude private routes synchronously during SPA navigation.
const tracker = document.createElement('script');
tracker.defer = true;
tracker.src = 'https://YOUR_ANALYTICS_HOST/js/script.js';
tracker.setAttribute('data-website-id', 'YOUR_SITE_ID');
tracker.afxEnabled = () => siteAllowsAnalyticsNow(); // Your consent and route policy.
// Run only after consent is granted:
document.head.append(tracker);
On withdrawal, set tracker.setAttribute('data-disabled', '') before clearing your analytics cookies or navigating/reloading. Removing the element alone does not stop its existing listeners. A disabled tracker stops future activity; it cannot cancel a request already sent. A script denied at startup stays inactive: create a new script after acceptance, and permanently disable the previous element before replacing it. Load only one active tracker.
Outgoing URLs retain standard UTM fields, ref/via, payment/subscription IDs and supported ad click IDs. Other query parameters, URL credentials and fragments are removed before transmission. This does not anonymize personal data embedded in a pathname or supplied as ordinary goal properties; exclude private routes and keep properties free of personal data.
Goals and identity
<button data-ml-goal="signup_completed">Create account</button>
For code-triggered goals use the window.analyticfast API after the tracker is ready, or use the npm package's bounded queue. Calls through optional chaining before script readiness are skipped:
window.analyticfast?.('goal', 'signup_completed', { plan: 'starter' });
window.analyticfast?.('identify', { user_id: 'internal-user-id' });
const ids = window.analyticfast?.attribution?.() ?? {};
Only identify customers using information they supplied. A goal is not a payment. See Revenue providers to connect checkout attribution.
Questions, answered.
How do I use plain html script with AnalyticFast?
Follow the Plain HTML script instructions on this page using your own website’s Site ID and configuration. Verify a real event before relying on the reports.
Where can I get setup help?
Contact support@analyticfast.com with the website domain and a redacted description. Do not send API tokens, signing secrets or personal customer data.