Sign inGet started
Reference

Tag JavaScript API

View as MarkdownOpen in ChatGPTOpen in Claude
Connect your agent
Add to CursorAdd to VS Code

The methods of window.nextanalytica and the attributes of the tag line, for events, people and consent.

Updated

The tag gives your site one object, window.nextanalytica, for what the tag can't see on its own: your own events, orders, who a signed-in person is and the visitor's consent. Everything else (page views, clicks, forms, scroll, errors, speed) it counts without code, so if that's all you need, you can stop reading here.

The line loads async, so the object exists once the tag has loaded. Code that runs early should check first: window.nextanalytica?.track("signup_completed"). Before consent, the tag counts cookieless: events go, but nothing is kept on the device and nobody is identified. See Cookieless counting and consent.

Tells the tag the visitor's answer from your cookie banner.

ArgumentTypeDescription
onbooleantrue when the visitor agreed to analytics, false when they said no.
window.nextanalytica.consent(true);

A yes starts the visitor's first-party id and lets identify work. A no removes everything the tag kept in the tab, on the device and in its cookie. A browser sending Global Privacy Control always counts as no.

window.nextanalytica.track(name, props, value)

Sends one of your own events, such as a sign-up or a demo request.

ArgumentTypeDescription
namestringThe event's name, at most 60 characters. Use snake_case: signup_started.
propsobjectOptional. At most 10 properties; keys up to 40 characters, values up to 100.
value{ value, currency }Optional. What the event is worth, with a three-letter currency (EUR).
window.nextanalytica.track("demo_requested", { plan: "team" }, { value: 50, currency: "EUR" });

Works before consent. Never put an email, a name or other personal details in props.

window.nextanalytica.order(order)

Records a purchase, so revenue ties to the visit it came from.

FieldTypeDescription
refstringYour order's reference, at most 100 characters, so a repeated call counts once.
valuenumberThe order's total.
currencystringThree capitals: EUR, USD.
window.nextanalytica.order({ ref: "A-10492", value: 129.9, currency: "EUR" });

window.nextanalytica.identify(userId, props)

Names a signed-in person, so their visits on any device make one profile.

ArgumentTypeDescription
userIdstringYour own id for the person, never an email.
propsobjectOptional. At most 20 properties, such as plan or company.
window.nextanalytica.identify("u_4821", { plan: "team" });

Does nothing without consent. Call it where people sign in, and on page loads while they are signed in.

window.nextanalytica.group(type, key, props)

Puts the person in a group, such as their company or workspace.

ArgumentTypeDescription
typestringThe kind of group: company.
keystringThe group's id: acme.
propsobjectOptional. At most 20 properties of the group.
window.nextanalytica.group("company", "acme", { seats: 12 });

Does nothing without consent.

window.nextanalytica.setPersonProperties(props)

Updates properties of the identified person without sending an event.

window.nextanalytica.setPersonProperties({ plan: "business" });

At most 20 properties. Does nothing without consent.

window.nextanalytica.reset()

Forgets who the person is, on sign-out, so the next person on the same browser starts fresh.

window.nextanalytica.reset();

Attributes of the tag line

The tag line carries its settings as attributes. Most projects need only data-project.

index.html
<script async src="https://t.nextanalytica.app/t.js" data-project="na_…"></script>
AttributeValuesWhat it does
data-projectYour project keyRequired. Which project the visits belong to. Copy the whole line from the app or from your agent's get_tag.
data-consentgrantedThe page already has the visitor's consent when it loads.
data-cookielessoffWait for consent before sending anything, instead of counting cookieless.
data-vitalsallMeasure page speed on every page view, not one in ten.
data-domainsYour other domains, comma-separatedAfter consent, links to them carry the visitor. See Subdomains, domains and Safari.
data-searchURL parameters, comma-separatedKept for older lines; the current tag sends no site-search events.
Related
  • Metrics and dimensions: Every metric and dimension your agent can ask for in nextanalytica, with its key, unit, which way is better and how it's defined.
  • Sources: Every source you can connect to nextanalytica today, from Google Search Console to Odoo: what each one reads and how it connects.
  • Changelog: What shipped in nextanalytica, release by release, newest first: new sources, tools, tag features and fixes your agent can use today.
Still have questions?
Was this page useful?