Official JavaScript SDK for Moonito — a smart analytics and visitor filtering platform designed to protect your website from unwanted traffic, bots, and malicious activity while providing deep visitor insights.
moonito-js is a lightweight JavaScript snippet for integrating your website with the Moonito Visitor Analytics and Traffic Filtering API.
Key Features:
- Real-time bot protection — Block crawlers, scrapers, and malicious bots
- Smart analytics — Track genuine visitors with accurate metrics
- Automatic filtering — Redirect unwanted traffic instantly
- Zero configuration — Just paste one line of code
- Universal compatibility — Works with any website or framework
Compatible with HTML, WordPress, React, Vue, Next.js, Angular, and all static/dynamic websites.
- Go to Moonito Analytics
- Register your domain
- Choose your security preferences
- Click Submit to get your integration code
Copy the script provided in your dashboard and paste it into every page (or your master template) just before the closing </head> tag:
<script defer data-public-key="YOUR_PUBLIC_KEY" data-blocked-page="https://example.com/blocked" src="https://cdn.jsdelivr.net/gh/moonito-net/lib/analytics.min.js"> </script><!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Your Web Application</title> <!-- Moonito Analytics Integration --> <script defer data-public-key="2Q4FnwYy6gaOY70F9GVxMNxxxxxxxxxx" data-blocked-page="https://google.com" src="https://cdn.jsdelivr.net/gh/moonito-net/lib/analytics.min.js"> </script> </head> <body> <main> <h1>Welcome to My Website</h1> <p>This is an example page with Moonito Analytics protection enabled.</p> </main> </body> </html>Add the script to your theme's header.php file before </head>, or use a plugin like Insert Headers and Footers.
Add to your pages/_document.js (Next.js) or public/index.html (Create React App):
// Next.js: pages/_document.js import { Html, Head, Main, NextScript } from 'next/document' export default function Document() { return ( <Html> <Head> <script defer data-public-key="YOUR_PUBLIC_KEY" data-blocked-page="https://example.com/blocked" src="https://cdn.jsdelivr.net/gh/moonito-net/lib/analytics.min.js"> </script> </Head> <body> <Main /> <NextScript /> </body> </Html> ) }Add to your public/index.html:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>Vue App</title> <!-- Moonito Analytics --> <script defer data-public-key="YOUR_PUBLIC_KEY" data-blocked-page="https://example.com/blocked" src="https://cdn.jsdelivr.net/gh/moonito-net/lib/analytics.min.js"> </script> </head> <body> <div id="app"></div> </body> </html>| Attribute | Type | Required | Description |
|---|---|---|---|
data-public-key | string | ✅ Yes | Your Moonito API public key from the dashboard |
data-blocked-page | string | ✅ Yes | URL to redirect unwanted visitors (e.g., https://example.com/blocked) |
defer | — | Recommended | Loads script asynchronously without blocking page rendering |
- Script loads when your page loads (deferred for performance)
- Visitor evaluation happens automatically in the background
- Analytics recorded for legitimate visitors
- Unwanted traffic blocked and redirected to your specified URL
- Dashboard updated with real-time visitor statistics
- Install the script on your website
- Visit your website in a browser
- Check the network tab — You should see a request to Moonito's analytics endpoint
- View analytics at https://moonito.net/analytics
✅ E-commerce sites — Block fake traffic and ad fraud
✅ Landing pages — Get accurate conversion metrics
✅ Blogs & content sites — Filter bot traffic for real engagement data
✅ SaaS applications — Protect signup forms from spam
✅ APIs & web apps — Prevent scraping and abuse
- Lightweight: ~5KB minified
- Non-blocking: Uses
deferattribute - CDN hosted: Fast global delivery via jsDelivr
- No dependencies: Pure JavaScript, no jQuery required
| Browser | Minimum Version |
|---|---|
| Chrome | 60+ |
| Firefox | 60+ |
| Safari | 12+ |
| Edge | 79+ |
| Opera | 47+ |
A: No. The script uses the defer attribute, which loads asynchronously without blocking page rendering.
A: Yes! It works with React, Vue, Angular, and other SPAs.
A: Your website continues to work normally. The script fails gracefully.
A: Log in to your Moonito Analytics Dashboard.
- Website: https://moonito.net
- Documentation: Integration Guide
MIT License © 2025 Moonito
javascript analytics, moonito sdk, visitor filtering, bot protection, traffic analytics, website security, spam prevention, fraud detection, analytics snippet, visitor tracking, real-time analytics, web protection sdk
Moonito — Stop Bad Bots. Start Accurate Web Analytics.