Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Call tracking script reference

Reference the Steer Phones DNI snippet, configuration options, browser methods, requests, and data handling.

This page documents the snippet and browser client used for Dynamic Number Insertion (DNI).

What the snippet contains

The generated snippet includes an anti-flash style for elements tagged with data-steer-dni. Those elements start at opacity: 0, become visible when the client adds dni-loaded, and reveal automatically after three seconds if that class is not added.

The snippet also creates one asynchronous loader for /v1/dni.js and calls SteerDNI.init({ phoneSystemId, fallbackNumber }). The external client script does not block the page while it downloads.

The script response is cached for one hour and may be served stale while revalidation runs for up to 24 hours. A script update can therefore take about a day to reach every visitor.

Initialize a phone system

Call SteerDNI.init(options) with one configuration object for each phone system.

Option Description
phoneSystemId Required. Identifies the phone system whose tracking pool will be used.
fallbackNumber The number the client reveals if an allocation request fails. If omitted, the original page number is revealed. Bots recognized by the API and exhausted pools receive the pool’s fallback number in the API response.
apiUrl The API origin only, with no path. Use it when the client is not loaded from a URL ending in /v1/dni.js; otherwise the client derives its API origin from that script URL.
selectors An array of CSS selectors that replaces the default data-steer-dni lookup for this phone system. The generated anti-flash style only covers data-steer-dni elements, so selector-matched elements may briefly show the original number.

Calling init() again for the same phone system replaces its options and requests an allocation again. Before the client loads, queued calls for one phone system are consolidated to the last options. Once the client is live, each call is applied and starts another allocation request. The loader itself is guarded so it appends the client script only once.

Browser methods

  • SteerDNI.refresh(phoneSystemId?) requests a new allocation for the named phone system, or for every initialized system when the argument is omitted. Call it after client-side route changes.
  • SteerDNI.getSession(phoneSystemId?) returns the current allocation result for the named system. With no argument, it returns a result only when exactly one phone system is initialized; otherwise it returns null.

An allocation result may include these useful fields:

Field Meaning
phoneNumber The number returned by the pool.
formattedNumber The display form of that number.
expiresAt The current session expiration time, or null for a fallback-only result.
sessionToken The token used to restore the session and send heartbeats, or null when no session was created.
poolExhausted Whether the pool could not lend a tracking number.
swap false when the visit does not match a matching-mode pool and the page should keep its own number.

getSession() returns null for an uninitialized phone system or an untracked visit. A bot or exhausted pool can return a fallback allocation result instead, with sessionToken: null and poolExhausted: true.

Number elements and display formatting

By default, the client finds elements whose data-steer-dni value matches the phone system ID. When a number is replaced, it adds dni-loaded to the element. North American numbers in E.164 format are displayed as (555) 123-4567; other number formats are left as stored.

The selectors option replaces the default tag lookup for its phone system. Selectors search the current page’s own document; they cannot reach into an iframe. The snippet’s anti-flash style continues to cover only elements tagged with data-steer-dni.

Requests and content security policy

Request When it runs
GET /v1/dni.js The snippet loads the browser client.
POST /v1/allocate On initialization and each refresh.
POST /v1/heartbeat Every 60 seconds by default while the tab is visible; skipped while the tab is hidden.

The DNI API’s CORS policy allows any website origin (*), so there is no Steer Phones-side domain allowlist to configure. If your site’s Content Security Policy restricts external origins, allow the origin shown before /v1/dni.js in script-src and connect-src. The generated snippet also has inline JavaScript and CSS, which must be permitted by the policy’s nonce or hash rules.

Data sent and stored

An allocation request can include the current page URL, referrer, utm_* parameters, gclid, fbclid, msclkid, browser user agent, and a random visitor ID. It also identifies the phone system and can include the current session token so the client can keep the visitor’s allocation.

The DNI client does not read cookies, form contents, or keystrokes, does not perform session replay, and does not send a visitor’s name or email address.

The browser stores the random visitor ID in local storage under steer_visitor_id. It stores the current session under steer_dni_session:<phone-system-id>, including the allocation information needed to continue it. Expired and converted visit records are pruned after about 30 days. A DNI session record does not include an IP address, though the API uses the request IP for rate limiting.

The script uses browser storage and a persistent random identifier for marketing attribution. Mention this behavior in your privacy policy and check with your privacy-compliance contact whether consent is required. If your site gates the snippet behind a consent banner, load it only after consent; until then, visitors see the page’s own number.

Crawlers and browser support

The API recognizes crawlers and headless-browser user agents and returns the pool fallback instead of lending a tracking number. Set that fallback to your main business number so automated checkers and search engines receive a consistent number.

The client relies on browser fetch and local storage, available in current versions of major browsers. If local storage is unavailable, the client can still request and swap a number, but it cannot persist the visitor ID or session across full page loads. The visitor may therefore receive a different number on each page view.