Plain HTML / Django templates

Add analytics to any server-rendered project — Django, Rails, Laravel, static sites — with a single script tag. No npm, no bundler, no build step required.

1. Add the script tag

Paste this inside <head> or just before </body> in your base template. Replace proj_xxxx and pk_xxxx with your project ID and API key from the dashboard.

html
<!-- base.html / base template -->
<script
src="https://cdn.jsdelivr.net/npm/nohmo@latest/dist/n.min.js"
data-project="proj_xxxx"
data-api-key="pk_xxxx"
defer
></script>

Note: The defer attribute makes the script load without blocking the page render and ensures window.nohmo is ready before any inline scripts run after the page loads.

2. That's it — auto-tracking is on

As soon as the script loads, the following are tracked automatically with no extra code:

EventTrigger
PAGE_VIEWOn every page load
TIME_SPENTWhen the tab is hidden or the page is closed
SCROLL_DEPTHAt 25%, 50%, 75%, 100% scroll milestones
CLICKAny click on a link, button, input, or form element
RAGE_CLICKThree or more rapid clicks in the same spot

3. Track custom events

Use window.nohmo.send() from any inline script or event handler.

html
<!-- inline event handler -->
<button onclick="window.nohmo.send('signup_clicked', { plan: 'pro' })">
Sign up
</button>
<!-- or from a <script> block -->
<script>
document.getElementById('buy-btn').addEventListener('click', function () {
window.nohmo.send('purchase_started', { productId: '{{ product.id }}', price: {{ product.price }} })
})
</script>

4. Identify users (Django example)

After the user logs in, call window.nohmo.identify() to link the device to a real user. All anonymous events fired before login are retroactively attached to that user.

html
{% if user.is_authenticated %}
<script>
window.nohmo.identify('{{ user.pk }}', '{{ user.email }}')
</script>
{% endif %}

Note: identify() takes a user ID as the first argument and an optional email as the second. You can also pass a third argument — any JSON object — as extra metadata stored on the user profile.

API reference

MethodArgumentsDescription
window.nohmo.send(event, data?)event: string, data?: objectTrack a custom event with optional data payload
window.nohmo.identify(userId, email?, meta?)userId: string, email?: string, meta?: objectLink this device to a real user identity

CDN URL

The script is served from jsDelivr, which mirrors every npm package automatically. The URL always resolves to the latest stable release:

bash
https://cdn.jsdelivr.net/npm/nohmo@latest/dist/n.min.js

To pin to a specific version (recommended for production), replace @latest with a version number, e.g. @0.3.11.