Analytics
On a site with full tracking, Digize adds its tracker to every HTML page, and it records page views and the usual events by itself. digize.analytics is for what only your code knows: a signup, a quote, a step of a wizard. Events show up on the workspace’s Analytics pages with the tracker’s own.
import { createSiteClient } from "@digize/sdk";
const digize = createSiteClient();digize.analytics.track("quote_requested", { label: "Wholesale", value: 250 });track(name, props)
Section titled “track(name, props)”name |
1 to 40 letters, digits, _, ., : or -, and not one of the tracker’s own events (pageview, click, rage_click, outbound, download, mailto, tel, form_start, form_submit, scroll, engagement, js_error). |
props.label |
Up to 120 characters. |
props.value |
A number, such as an amount in minor units. |
| Other properties | Not recorded by Digize; with a Google tag on the page, the tracker sends them to Google with the event. |
It answers whether the event was taken: false for a name the beacon would refuse, for a visitor who opted out, and outside a browser.
How events are sent
Section titled “How events are sent”- The tracker is on the page and loaded:
trackhands the event to it (window.digize.track), so it shares the tracker’s session and batches, and goes to the Google tag too. - The tracker is on the page but hasn’t loaded yet (it loads deferred): the event waits in the queue the tracker plays back when it starts.
- There’s no tracker on the page, such as one answered with
x-digize-tracking: off: the client speaks the tracker’s protocol itself. It keeps the same session insessionStorage, batches events for a second (or 20 at a time), and posts them to/_platform/eon the page’s own hostname, the last ones as the page is hidden or closed.
Either way, nothing is sent for a browser with Global Privacy Control on or with localStorage["digize:ignore"] set to "1", and nothing sets a cookie.
pageview(options)
Section titled “pageview(options)”The tracker records page views itself, single-page navigations included, so on a page with the tracker pageview() does nothing and answers false. On a page without it, call it on each view:
digize.analytics.pageview(); // this page, with document.titledigize.analytics.pageview({ path: "/checkout/shipping", title: "Shipping" });The first page view of a session is counted as its entrance.
flush()
Section titled “flush()”Events without the tracker wait up to a second to go in one batch. flush() sends them now, such as just before a single-page app replaces the page:
digize.analytics.track("signup", { label: "Pro" });digize.analytics.flush();In a Worker
Section titled “In a Worker”Analytics come from the visitor’s browser: the beacon only takes posts from the site’s own pages, and a site’s Worker doesn’t reach it. In a Worker, track and pageview send nothing and answer false, so shared code that runs on both sides doesn’t need to check. Requests themselves are already counted at the edge, for every site.