Skip to content

The page API

Once loaded, the script exposes window.EodiaAnalytics. Six methods, none of which returns a value:

EodiaAnalytics.track('newsletter_signup', { placement: 'footer' })
EodiaAnalytics.identify(jwt) // or null to forget it
EodiaAnalytics.page() // a page view, by hand
EodiaAnalytics.optOut() // the visitor refuses measurement
EodiaAnalytics.optIn() // they withdraw their refusal
EodiaAnalytics.consent(true) // "with consent" mode: the consent management platform calls it

Sends an event, attached to the current page view.

EodiaAnalytics.track('review_posted', { rating: 5, item_id: 'KA2' })
RuleLimit
Namelowercase letters, digits and _ . : -, 64 characters at most: ^[a-z0-9_.:-]{1,64}$
Properties30 at most; keys of 40 characters at most (A-Z a-z 0-9 _ . -)
Valuestext (500 characters at most), number, boolean or null
itemsreserved for e-commerce events

An event outside these limits is rejected (“Invalid payload”) and shows up in the Verification tab. An event received but not declared is kept: it shows up in the Metadata tab, where one click declares it, with a label, a description and the type of each property. Once declared, it has its own view, analytics.evt_<name>, with one typed column per property.

Attaches the rest of the visit to a signed-in visitor, through a JWT signed by your server with the site secret, like data-identity. identify(null) forgets it (on sign-out). See the signed-in visitor.

Counts a page view by hand: with data-auto="false", or when the page changes state without changing address (a step in a multi-page form, a dialog that acts as a page).

optOut() records the visitor’s refusal in their browser (localStorage), deletes the measurement cookie and discards anything waiting to be sent; nothing is sent afterwards, from that browser, for that site. optIn() lifts the refusal. This is the opt-out link to offer in the privacy policy:

<a href="#" onclick="EodiaAnalytics.optOut(); this.textContent = 'Audience measurement disabled'; return false">
Stop measuring my visit
</a>

The browser’s Global Privacy Control signal counts as a refusal in the same way, without a click.

For sites in with consent mode: the site’s consent management platform calls consent(true) when the visitor accepts audience measurement. The script then switches to the measurement cookie; consent(false) deletes it and returns to the daily hash. In the other modes, the call has no effect. See tracking modes.

The tag carries defer: the script arrives after the rest of the page. A call made before it would be lost. Place this bootstrap before the tag: it records the calls in a queue, which the script replays in order when it arrives.

<script>
window.EodiaAnalytics = window.EodiaAnalytics || { q: [] };
['track', 'identify', 'page', 'optOut', 'optIn', 'consent'].forEach(function (m) {
EodiaAnalytics[m] = EodiaAnalytics[m] || function () {
EodiaAnalytics.q.push([m, [].slice.call(arguments)]);
};
});
</script>
<script defer src="https://stats.example.com/a.js" data-site="s_arvordemo001"></script>

When it arrives, the script first replays the identity, the consent and the refusal, then counts the page view, then replays the events and the manual page views: a track called early is thus attached to the right page and the right visitor.

declare global {
interface Window {
EodiaAnalytics?: {
track(name: string, props?: Record<string, string | number | boolean | null | object[]>): void
identify(token: string | null): void
page(): void
optOut(): void
optIn(): void
consent(given: boolean): void
}
}
}
window.EodiaAnalytics?.track('store_locator', { city: 'Quimper' })

The ?. operator keeps the page intact when the script is blocked.

eodia analytics is free software by Eodia.