Know what turns attention into customers
One lightweight script gives you pageviews, visitors, sources, campaigns, devices, custom events, revenue, and a live 3D visitor room. Identify signed-in users to see real customer names and avatars; unidentified traffic gets a stable private nickname and avatar. Pro adds goals, conversion journeys, and the AI crawlers ordinary browser analytics cannot see.
Install in three steps
- Open Growth Analytics, connect the website, and copy its generated snippet. Every install ID is locked to the domain you entered.
- Paste the snippet once in the site's
<head>. Put it before the closing</head>tag or in your framework's shared root layout. - Visit the live site, move to another page, then return to the analytics dashboard. The first pageview normally appears within seconds.
<script defer data-site-id="mla_YOUR_SITE_ID" src="https://www.mentionleads.com/js/analytics.js" ></script>
What is automatic
- Initial pageviews and client-side navigation in React, Next.js, Vue, and other SPAs.
- Guest and identified visitors, 30-minute sessions, engaged time, bounce rate, and a live 3D globe.
- Referrer domains plus
utm_source,utm_medium, andutm_campaign. - Browser, operating system, device class, and coarse hosting-network location.
- Do Not Track. When the browser sends
DNT: 1, the script does not run.
Paths are stored without query strings or fragments, so emails, tokens, and other URL parameters are not collected. Raw IP addresses are used only for transient abuse throttling and are never written to the analytics database.
Show signed-in users by name
Call mentionleads.identify() after your own app authenticates a user. Use a stable internal account ID—not an email address—as the first argument. MentionLeads hashes that ID per connected site before storage, so the original value never appears in the dashboard or API. The optional name and avatar are what your team sees in the live room.
// Run this after your app restores the signed-in user.
const traits = {
name: user.name,
avatar: user.avatarUrl // Optional; must use HTTPS.
};
if (window.mentionleads?.identify) {
window.mentionleads.identify(user.id, traits);
} else {
// Safe when your auth code runs before the analytics script is ready.
window.mentionleads = window.mentionleads || [];
window.mentionleads.push(['identify', user.id, traits]);
}Reset identity on sign-out
Call reset()during logout, especially on shared devices. It clears the tracker's visitor and session IDs, removes the in-memory identity, and starts a fresh guest session.
// Call this as part of sign-out so the next person on this // browser starts with a fresh visitor and session. window.mentionleads?.reset();
Track product events
Call mentionleads.track() after a meaningful action such as signup, checkout, demo booked, or trial activated. Event names are normalized to lowercase snake case. Properties may be strings, numbers, or booleans.
// Track any meaningful action after the script has loaded.
window.mentionleads.track('signup', {
plan: 'starter',
source: 'pricing_page'
});Track a click without JavaScript
Add data-ml-event to any clickable element. Other data-ml-*attributes become event properties.
<button data-ml-event="demo_booked" data-ml-location="pricing" > Book a demo </button>
Connect Stripe revenue
Open your website's setup inside Growth Analytics and choose Attribute revenue. The Stripe button opens a restricted-key form with read-only access preselected for Charges, Payment Intents, Checkout Sessions, and Invoices. MentionLeads rejects secret, publishable, test, and unrestricted keys; the accepted live key is encrypted at rest and scoped to that analytics site.
Successful charges and refunds sync automatically. To connect a payment to its original source, campaign, and landing page, pass the tracker's opaque visitor and session IDs through your own checkout request and attach them to Stripe metadata:
// Send MentionLeads' opaque visit IDs with your checkout request.
const attribution = window.mentionleads?.getAttribution();
await fetch('/api/create-checkout', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
priceId: 'price_...',
visitorId: attribution?.visitorId,
sessionId: attribution?.sessionId
})
});// Your backend: copy the IDs into Stripe metadata.
// Validate your price and all other checkout fields server-side as usual.
const metadata = {
mentionleads_visitor_id: visitorId,
mentionleads_session_id: sessionId
};
const checkout = await stripe.checkout.sessions.create({
mode: 'payment',
line_items: [{ price: priceId, quantity: 1 }],
success_url: 'https://example.com/thank-you',
cancel_url: 'https://example.com/pricing',
metadata,
payment_intent_data: { metadata }
});
// For recurring Checkout, use mode: 'subscription' and add:
// subscription_data: { metadata }Track revenue without Stripe
Send revenue in major currency units. The example below records $49, not 49 cents. Use one currency per site so totals remain meaningful. When Stripe is connected, imported Stripe payments become the authoritative revenue total to prevent this event from being counted twice.
window.mentionleads.track('purchase', {
revenue: 49,
currency: 'USD',
plan: 'pro'
});Read and write from your backend
Starter and Pro can create a scoped token on the API & MCPpage. Grant only analytics read, analytics write, or crawler write access, then limit the token to every connected website or a specific set. Tokens are shown once, stored as a one-way hash, and can be revoked immediately.
List the websites visible to the token, then request a traffic summary for one site:
curl https://www.mentionleads.com/api/analytics/sites \ -H "Authorization: Bearer mlk_YOUR_TOKEN"
curl "https://www.mentionleads.com/api/analytics/summary?site=mla_YOUR_SITE_ID&days=30" \ -H "Authorization: Bearer mlk_YOUR_TOKEN"
Send a trusted server-side event
Enable Server-side events on the token. Keep it in an environment variable and never expose it in browser code. Event, visitor, and session IDs must be stable strings; MentionLeads hashes visitor and session IDs per site before storage.
curl https://www.mentionleads.com/api/analytics/collect \
-H "Authorization: Bearer mlk_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"siteId": "mla_YOUR_SITE_ID",
"type": "event",
"name": "signup",
"eventId": "evt_UNIQUE_ID",
"visitorId": "usr_INTERNAL_ID",
"sessionId": "session_INTERNAL_ID",
"path": "/pricing"
}'Turn events into goals
On Pro, open the Conversion goals card and choose either an event such assignup or a destination path such as /thank-you. The dashboard then calculates completions, converting sessions, conversion rate, revenue, and the paths people took before converting. Goals are preserved if you downgrade, but remain hidden until Pro is active again.
Privacy and consent
- No raw IP address, URL query string, or request body is stored.
- Browser-generated visitor and session IDs are one-way hashed per site before storage.
- Supplied user IDs are also one-way hashed per site. Optional names and avatar URLs are stored only when your app calls
identify(). - The script uses first-party local and session storage; it does not use third-party cookies.
- Event payloads and property counts are bounded, and duplicate event IDs are counted once.
- Starter retains 30 days, Pro 90 days, and Agency 365 days of event history.
Privacy rules differ by location and business. If your consent policy requires opt-in analytics, load the script only after the visitor accepts that category. MentionLeads does not replace your site's consent notice or legal review. If you use identify(), disclose that your analytics processor receives the signed-in user's display name and optional avatar, and only call it where your notice, consent, and applicable law allow.
Plan limits
| Plan | Sites | Events / site / month | History | Live 3D room | Goals + journeys |
|---|---|---|---|---|---|
| Starter | 1 | 10,000 | 30 days | Included | — |
| Pro | 5 | 100,000 | 90 days | Included | 10 per site |
| Agency | 25 | 500,000 | 365 days | Included | 30 per site |
Human traffic is only half the story
Browser scripts cannot see ChatGPT, Claude, Perplexity, search indexers, or training crawlers fetching raw HTML. Pro combines this dashboard with the optional server-side companion while keeping human and machine traffic clearly separated. Follow the AI crawler tracking guide to add that layer.
Troubleshooting
- No pageviews: confirm the snippet contains the exact site ID and is running on the connected public domain.
- Localhost is quiet: localhost traffic is intentionally ignored. Test on a preview URL connected as its own site or on the live domain.
- Some visitors are missing: Do Not Track, content blockers, consent choices, and disabled JavaScript can all prevent browser analytics.
- A custom event is missing: call it after the tracker loads and keep the event name under 64 characters.