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. Connect recurring billing for MRR, ARR, LTV, churn, revenue movement, and retention cohorts. Pro adds goals, closed-loop customer 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://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, Invoices, and Subscriptions. MentionLeads rejects secret, publishable, test, and unrestricted keys; the accepted live key is encrypted at rest and scoped to that analytics site.
Successful charges, refunds, and subscription lifecycle changes 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 }Read recurring revenue and retention
Once recurring billing data is available, the SaaS revenue panel uses the latest synced subscription lifecycle for current MRR, ARR, and LTV. The selected date range controls churn and revenue-movement metrics.
- MRR and ARR: active recurring revenue normalized to a month, and MRR multiplied by 12.
- LTV: recorded paid revenue divided by distinct paying customers.
- Churn and movement: customer churn, churned subscriptions, expansion and contraction MRR, upgrades, downgrades, cancellation requests, and net MRR movement.
- Retention cohorts: customers grouped by first subscription or recurring-payment month, with the retained share shown from month zero through month five.
Keep one primary currency per site. One-time payments remain in revenue analytics, but recurring metrics require subscription or recurring-invoice data from the billing provider.
Close the customer journey loop
On Pro and Agency, the customer journey view connects acquisition to retention as visitor → potential customer → signup → payment → retained. Source and campaign come from the first-party tracker; payments and renewals come from the connected billing history.
- Call
identify()after sign-in so anonymous activity can continue under the same known customer. - Track standard milestones such as the technical
leadandsignupevents when they occur. - Attach the MentionLeads visitor and session IDs to checkout metadata so payment and renewal revenue can join the earlier visit.
Each journey keeps the acquisition context, completed stages, latest activity, and attributed revenue together. Stages remain visibly incomplete when the corresponding event or billing link has not been recorded.
Track revenue without Stripe
Send revenue in major currency units. The example below records $39, not 39 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: 39,
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://mentionleads.com/api/analytics/sites \ -H "Authorization: Bearer mlk_YOUR_TOKEN"
curl "https://mentionleads.com/api/analytics/summary?site=mla_YOUR_SITE_ID&days=30" \ -H "Authorization: Bearer mlk_YOUR_TOKEN"
Use analytics from MCP or the CLI
Enable both Potential customer intelligence and Growth analytics on the token to give Claude Code, Cursor, or another MCP client read-only analytics tools. The downloadable Node CLI uses those same scoped tools for sites, overviews, live visitors, goals, funnels, saved segments, and recent visitors. The analytics overview returns a saaslifecycle summary with retention cohorts and a customerJourneys array that closes acquisition, product milestones, payments, and retention into one path when that data is available.
curl -fsSL https://mentionleads.com/mentionleads-cli.mjs -o mentionleads-cli.mjs MENTIONLEADS_API_KEY=mlk_YOUR_TOKEN \ node mentionleads-cli.mjs sites MENTIONLEADS_API_KEY=mlk_YOUR_TOKEN \ node mentionleads-cli.mjs overview mla_YOUR_SITE_ID --days 30
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://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.