Website tracking
Install one snippet so Smileline finds your website's forms, captures their submissions and attributes every enquiry.
By the end of this page the Smileline script will be live on your website, the setup checklist will be green, and enquiries will arrive with their marketing attribution attached — without changing any of your existing forms.
What the script does
- Finds your forms. It scans each page for enquiry forms and lists them under Settings → Website with their field names and labels, ready to confirm. See Website forms.
- Captures submissions. Once a detected form is confirmed, every submission becomes a lead — your form keeps working exactly as before; Smileline listens alongside it.
- Attributes enquiries. UTM parameters, ad click IDs, the landing page and the referrer travel with each submission, so attribution works without any extra wiring.
- Swaps in tracking numbers. With call tracking set up, the script replaces your published phone number with the visitor's rotating tracking number — every phone-shaped number on the page, the specific numbers a pool lists, or elements you mark with
class="sl-phone"— so calls get the same attribution as form submissions. - Counts page views. Each page view, and how long the page stayed on screen, feeds website analytics under Ads → Analytics. Only the page's path is recorded, never its query string or fragment, and a view carries the visitor ID only when your consent setting allows it.
- Runs page tests. On an Astro site with the Astro integration, it marks which version of a page a visitor saw, for A/B page tests.
- Records visits for heatmaps and replays. Unless you switch it off, it records how each page is used — what's on screen, scrolling and clicks — for heatmaps and session replays, under your consent setting and with everything typed or chosen in a form masked. See Heatmaps and session recordings.
- Sends nothing else. Beyond those and the one number-assignment request call tracking needs, the only other thing it loads from outside Smileline is consent-gated: OpenAI's measurement pixel while ChatGPT Ads conversion feedback is live — see Privacy and consent.
Only owners and managers can see Settings → Website and manage tracking.
Install the snippet
Until the script is installed, the tracking page is the install flow: a status band at the top, then an Install card with three numbered steps.
Go to Settings → Website. If tracking isn't set up yet, the status card reads Tracking not set up, so click Install. (Later, the same card links to Tracking settings.)
Your website address. Save it and Smileline checks which platform the site runs on, so step 3 shows instructions for WordPress, Wix, Squarespace, Webflow, Shopify or a custom build. If it can't tell, you get generic steps and a Check again link.
Copy the install code. Three tabs, and you only need one of them. Snippet is the default and suits every website; npm SDK is for custom sites and single-page apps, and is covered under Developer SDK; Astro is for sites built with Astro, and is the only way to run A/B page tests — see Astro integration. The snippet looks like this, but copy yours from Smileline, because it carries your practice's site key and regional hostname:
<script>if(typeof window.sl!=="function"){const s=(...a)=>{s.q.push(a)};s.q=[];window.sl=s}</script><script async src="https://widget-eu.smileline.io/sl.js" data-site="pk_YOUR_SITE_KEY"></script>That is an EU example; US practices receive a widget-us.smileline.io address. The first, inline tag sets up the script's command queue, so your page's own code can call sl(…) before the script has loaded (see Developer SDK); keep both tags.
Keep the complete data-site value, including pk_. Configuration, form discovery and tracking-number requests use that same prefixed key. A missing prefix produces a 404 and leaves Snippet installed unchecked.
Copy for AI under any tab puts a ready-made brief on your clipboard for ChatGPT, Claude, Cursor or your developer: the exact tag (or SDK call, or Astro setup), where it goes, what the script does, your consent setting and the Content Security Policy entries a strict site needs. It stays available beside the tabs once the script is live.
Paste it into your platform. Add it to every page of your website, ideally in a site-wide header. If someone else looks after the site, use Email these steps to a developer: Smileline emails them the snippet with the platform-specific steps. One send per hour.
Once the script has loaded from your website, the numbered steps drop away and the Install card keeps the three tabs and Copy for AI, so you can still move an Astro site to the integration later.
The script updates itself (it is cached for about five minutes), so you install it once. If your platform requires pinned assets, download sl.js and serve it yourself under Advanced → Self-hosted script, and you then own updates.
Watch the setup checklist
Under the status band, four steps confirm the setup with real events from your website. The page refreshes itself while you install, and only the next outstanding step shows its explanation, so the list stays short. Once all four are green the list disappears and the band alone reports that tracking is live.
| Step | Turns green when |
|---|---|
| Snippet installed | The script has phoned home from your website in the last day. |
| Forms detected | The script found at least one form to capture. |
| Test enquiry received | Any form on your site was submitted, and the submission arrives even before mapping. |
| Mapping confirmed | You confirmed a detected form's field mapping so its submissions open journeys. |
For the last two steps, submit one of your own forms as a test, then confirm its mapping. See Confirm a detected form.
Privacy and consent
The script is deliberately quiet. It makes exactly four kinds of request, plus one more when call tracking is on and one more while heatmaps and session recordings are on, and loads one third-party script only while ChatGPT Ads conversion feedback is live:
- Loading its configuration when a page opens.
- Reporting a page view when a page opens (or a single-page app moves to a new page), and a short follow-up when the visitor leaves or hides the page, with how long it was on screen. It sends the page's path (never its query string or fragment), the referring website's domain, campaign parameters and, only when your consent setting allows it (below), the visitor ID. Known crawlers are skipped. Smileline adds the visitor's country, city and device type from the request and does not store their IP address or browser user agent with the view.
- Reporting a newly found form — field names, labels and input types only. Nothing a visitor typed is ever included. A form Smileline already knows is reported again at most once per browser tab, and only once the visitor ID can be stored.
- Submitting a form's contents when the visitor presses submit — the only moment enquiry data leaves the browser.
- Asking for a tracking number when a call-tracking pool is live. It sends the visitor ID, the page address and the visitor's attribution (campaign parameters, referrer, landing page, the marketing cookies listed under Attribution, screen size and time zone) — nothing the visitor typed. It runs once per browser tab per 30-minute window, whatever the visitor answered on your cookie banner. Until the visitor ID can be stored (under either waiting option, before a grant or after a refusal), the request carries only the page address and referrer — no cookies, screen size or time zone — nothing is stored on the device, and each page gets its own number, so a call is credited to the page it was made from. Once the ID can be stored, the visitor keeps one number across pages. Known crawlers are skipped.
- Loading OpenAI's measurement pixel (
https://bzrcdn.openai.com/sdk/oaiq.min.js) once ChatGPT Ads conversion feedback is connected, enabled and provisioned. It sends OpenAI one page view per page so ChatGPT ads can be attributed. It is loaded only once the visitor ID can be stored, never for known crawlers; a later denial is passed to OpenAI, and it disappears automatically when feedback is disabled or the account is disconnected. A strict Content Security Policy must allowscript-src https://bzrcdn.openai.com,connect-src https://bzr.openai.com https://bzrcdn.openai.comandimg-src https://bzr.openai.com. The tracking page shows ChatGPT pixel: configured or not configured. - Uploading a recording of the page for heatmaps and session replays, while Heatmaps and session recordings is on: every 5 seconds while the page is open, and a last time when the visitor leaves it. Only the page's path is kept; query strings and fragments are removed before upload. A second Smileline script,
sl-insights.js, does the recording; it loads only for visitors whose browser stores the visitor ID under the analytics rule below, and what they type or choose in forms never leaves their browser. See Heatmaps and session recordings.
It also honours consent, according to Visitor id and consent under Advanced on the tracking page:
- Store the visitor id immediately (the default, and what call-tracking services generally do): the visitor ID and attribution are stored as soon as the script loads. Your cookie banner decides whether the script loads at all.
- Wait for a consent-mode / TCF grant or Always wait for consent: it reads Google Consent Mode and IAB TCF signals from your cookie banner automatically, and your own code can signal consent explicitly through the SDK. Until storage consent is granted, the visitor's attribution lives in memory only — nothing is written to cookies, local storage or session storage, and the tracking number is still shown, page by page (see above). A later grant upgrades it.
- Under every setting, an explicit denial through the SDK wipes anything previously stored — the cookie, the attribution record, the cached tracking number and the form-discovery marks below — and tells OpenAI's pixel, when loaded, to stop.
- Website analytics follows the same setting, with one difference: a page view always counts towards your anonymous totals, but carries the visitor ID only when analytics is allowed too. Under Store the visitor id immediately that is unless the visitor refuses analytics, on your cookie banner or through your own code; under either waiting option, only once analytics storage is granted (a grant for advertising alone isn't enough). A view without the ID counts on the Overview tab of Ads → Analytics but never shows on its Visitors tab, and is never counted in an A/B page test. If consent is given later on the page, the view is sent again with the ID.
- Heatmaps and session recordings follow that analytics rule exactly: a page is recorded only while the visitor ID can be stored for analytics. If consent is given later on the page, recording starts then; a later refusal stops it at once.
- A browser sending the Global Privacy Control signal (
navigator.globalPrivacyControl, required by California and a dozen other US states) is treated as that same explicit denial, ahead of the consent setting — no site setting can opt out of a legally mandated opt-out. The script runs in memory only for that visitor: nothing is written to cookies or storage, no tracking number is requested (they see your published number), nothing is recorded for heatmaps or replays, and their form submissions still arrive with the page they were on but without a stored visitor id or first touch. - Each form submission carries the visitor's own consent choices for conversion feedback: a Reject on your cookie banner, an explicit SDK denial or a Global Privacy Control signal arrives as a refusal, and that enquiry is not shared with your ad platforms unless you switch on sending refused visitors' conversions for a platform. Your banner's starting state, before the visitor chooses anything, is not sent as a refusal.
- When storage is allowed, Smileline keeps a first-party visitor ID cookie (
_sl_vid, 400 days,SameSite=Lax; on a smileline.site address it is also set as__Host-_sl_vid, holding the same ID, which no other website on smileline.site can overwrite), an attribution record in local storage (_sl:v1, expiring after 180 days of inactivity), and, for the life of the browser tab only, the visitor's assigned tracking number (_sl:dni:v1:<site key>, 30 minutes) and marks for forms already reported (_sl:fd:…) in session storage. - A visit's first touch is recorded once and never replaced; the last touch is replaced only when a new session (after 30 minutes of inactivity) arrives with campaign parameters or an external referrer.
Visit-level analytics (each visitor's page views, and which version of a tested page they saw) are kept for 13 months in your practice's region; after 12 months each day is folded into daily totals that name no visitor, and those are kept. Query strings and fragments are never recorded. See Website analytics. Recordings for heatmaps and session replays are kept for 13 months in your practice's region, then deleted.
Heatmaps and session recordings
The script also records how visitors use each page of your website, for heatmaps and session replays, on the Heatmaps and Visitors tabs of Ads → Analytics. It is on by default. To stop it for the whole website, turn off Heatmaps and session recordings on the tracking page; only owners and managers can.
- Who is recorded follows your Visitor id and consent setting, as above: only visitors whose browser stores the visitor ID for analytics. Browsers sending Global Privacy Control and known crawlers are never recorded.
- Every form control is masked in the visitor's browser, before anything is sent: text boxes, text areas, drop-down lists, checkboxes, radio buttons and sliders, and any editable area (
contenteditable) with everything inside it. - Mask more yourself. Add
data-clarity-mask="true"to any element to mask it and everything inside it.data-clarity-unmaskis ignored, so nothing on your website can switch masking off. - Only your own website is recorded. Smileline's hosted forms, online booking page and other Smileline addresses never are.
- Your own reviews aren't recorded. While you look at a page's heatmap with the Smileline Chrome extension, that visit stops being recorded; its page view still counts. A page can do the same for itself with
sl("stopRecording"), which lasts until the page is next loaded and leaves consent as it is. - Page addresses. Only the page's path is kept; query strings and fragments are removed before upload.
- Browser support. Recording needs the
CompressionStreamfeature of current browsers. An older browser isn't recorded, and its page views still count. - Uploads happen every 5 seconds while a page is open, so a visit shorter than about 5 seconds may have no replay; its clicks and scrolling still count. Each website can upload up to 2 GB of recordings a day, far above real traffic. Past that, recording pauses until midnight UTC.
- Retention. Recordings are kept for 13 months in your practice's region. Erasing a patient deletes the recordings made under their visitor ID.
The data-clarity-* attributes keep the names used by Microsoft Clarity, whose open-source (MIT) recording code Smileline builds on. Nothing is sent to Microsoft, and a Microsoft Clarity tag you run yourself keeps working separately. Mention session recording in your website's privacy notice.
If Smileline is briefly unavailable
The script keeps working from the last configuration it loaded, stored in the visitor's browser (_sl:cfg:<site key>, no expiry). It is used only while Smileline cannot answer, and cleared as soon as Smileline says tracking is switched off or the key no longer exists. A form submission the script cannot deliver — a dropped connection, a busy or unavailable server — is held in that visitor's browser storage (one _sl:outbox:… entry per submission, naming the Smileline region it is for) and sent again on their next page view on your site until Smileline accepts it. The same holds for an enquiry your own code sends through the typed clients below, even while the script is still loading or is blocked. Each submission carries a stable event id, so delivering it twice never creates two leads.
Both entries hold the visitor's own submission on their own device and are written under every consent setting — they are not tracking, and nothing is read from them elsewhere. Mention them in your privacy notice alongside the cookies listed above.
Domain pinning
With domains pinned, detected forms only accept submissions from those hostnames — anything else parks for review instead of becoming a lead. Built forms are exempt: they submit from Smileline's own hosted-form origin and are protected by their bot check instead. Custom integrations are exempt too, because they post server-to-server.
On the tracking page, open Advanced and use Domain pinning to Pin up to ten hostnames. Pinning practice.com also covers www.practice.com and other subdomains. An empty list means pinning is off.
A submission from an unpinned domain still receives a success response — the sender learns nothing — and the parked submission appears in the review queue so a legitimate enquiry from a forgotten domain is never lost.
Form detection follows the same boundary: the script only registers forms found on pages belonging to your configured website address, its www twin and subdomains, or a pinned domain. Reports from any other host are ignored.
Pause tracking or rotate the key
Both live under Advanced on the tracking page.
- The Tracking live switch pauses tracking everywhere: installed scripts stop loading their configuration and go inert. While tracking is paused the status band says so and offers Resume tracking.
- Regenerate key mints a new site key. Snippets carrying the current key stop working immediately, so update the website straight afterwards.
- Configuration changes reach installed scripts within about a minute.
Astro integration
If your website is built with Astro, install the Smileline Astro integration instead of the snippet. It adds the same tracking script to every page, serves the script and its requests from your own domain (under /_sl/), and runs A/B page tests. Install one of the three — snippet, SDK or integration — never two.
Open the Astro tab in step 02 of the install card (it stays on the card once the script is live). It prints your setup with your site key and region filled in:
npm install @smileline/astro// astro.config.mjs
import { defineConfig } from "astro/config";
import smileline from "@smileline/astro";
export default defineConfig({
integrations: [smileline({ siteKey: "pk_YOUR_SITE_KEY", region: "eu" })],
});region is the Smileline region your practice's data lives in: eu for UK and EU practices, us for US practices. Copy it from the tab rather than typing it.
The server key
The integration also needs a server key, which lets it read the page tests you start and vouch for the visitors it forwards from your own domain.
On the Astro tab, click Create server key. Only owners and managers can.
Copy the key from the dialog. It's shown once and can't be recovered; if you lose it, click Rotate key for a new one.
Set it as SMILELINE_SERVER_KEY in the environment where your site runs — a secret in your hosting's settings, never in your code or anywhere a browser can read it — and deploy.
The tab then shows when the integration last checked in. Rotate key replaces the key; the previous one stops being accepted within two minutes, so set the new one straight away.
Render tested pages on demand
- A/B page tests split visitors on your site's server, so the project needs a server adapter (for example Cloudflare, Netlify, Vercel or Node), and both pages of every test must render on demand: add
export const prerender = falseto each. A fully static site still gets the tracking script and analytics, and the build warns that page tests are off. - A page under test is sent as a private, uncached response, and the integration removes CDN caching headers from it. Don't add CDN or edge caching rules for tested pages, or every visitor would get the same version.
- Leave the
/_sl/path free on your site: the integration's route lives there. If it is ever unavailable, the script talks to Smileline directly instead, so a strict Content Security Policy still needs the Smileline origins the Copy for AI brief lists.
Send enquiries from your own code
The script finds and captures your site's forms by itself. A form your own code submits (with fetch, a framework action or a multi-step widget) can hand its enquiry over with the integration's typed client instead. Mark that form with data-sl-form, so the script leaves it to your code; without it the script captures the form as well, and one enquiry becomes two leads:
<form id="contact" data-sl-form>…</form>import { captureLead } from "@smileline/astro/client";
const { outcome } = await captureLead("YOUR_FORM_TOKEN", {
first_name: "Amelia",
email: "amelia@example.co.uk",
});- While the script is live it carries the enquiry, with the visitor's attribution. Before it has loaded, or if it is blocked, the client keeps the enquiry in the visitor's browser first, with the consent the visitor has given so far, and sends it to Smileline itself through your site's
/_sl/route (straight to your region's API when that route can't pass it on), so nothing is lost. Whatever couldn't be sent goes again from the visitor's next page. outcomeisaccepted(Smileline has it),queued(kept in the browser and sent again on the visitor's next page, so treat it as sent),rejected(refused for good, such as an unknown token),failed(neither sent nor kept) orunconfirmed(no answer, and the browser couldn't keep it either). It never throws.- Each call is a new enquiry. To retry one yourself, pass the same
eventId(a UUID) each time —captureLead(token, fields, { eventId })— and it stays one lead. step("What is your age?")counts a step for A/B page tests, andconsent("granted")passes on your cookie banner's answer, from the same import. Both wait for the script if it hasn't loaded yet.
Practice details for website code
A website built in code can show your practice's details and Google reviews straight from Smileline, so a new opening time, a closure, a new team member or a new review appears on the site without anyone editing it.
On the tracking page, turn on Share practice details with website code. Only owners and managers can. It's off until you turn it on. Creating a server key doesn't turn it on; downloading your website does.
Two addresses serve the details, in your practice's region: https://api-eu.smileline.io for UK and EU practices, https://api-us.smileline.io for US practices.
GET /site/<site key>/practiceis public, like the tracking script: anyone with your site key can read it, so a page can call it from the visitor's browser. It returns your practice name, your main booking page's link (nullwhile online booking is off) and each location your main booking page shows, with its address, phone number, time zone and weekly opening hours. Each location also says whether it'sclosedToday(a closure you saved covers today), whether it'sopenNow, andvalidUntil: when those two can next change, such as the next opening or closing time or midnight. Fetch it again aftervalidUntil. The closure dates themselves are never in it.GET /site/<site key>/server-practiceis for your website's own server. It needs your server key in theX-Smileline-Server-Keyheader and answers401without it. On top of the public details it lists your team (active practitioners, with their role, photo and GDC number), your treatments, your Google review rating, your logo and each location's closures for the next 365 days. Never call it from a browser.GET /site/<site key>/reviewsis public too: the Google reviews the Reviews sections of your live Smileline website show (none when no page has one), with each one's author, rating, text and date, andexpiresAt, when Smileline must stop showing them. Google limits how long review text may be kept, so read them when the page is visited rather than storing them in your site. A website you download from Smileline does this on its own.
While the switch is off, or while tracking is paused, all three answer 404. The switch can't be changed while tracking is paused. The details are at most a minute old.
curl https://api-eu.smileline.io/site/pk_YOUR_SITE_KEY/practicecurl https://api-eu.smileline.io/site/pk_YOUR_SITE_KEY/server-practice \
-H "X-Smileline-Server-Key: $SMILELINE_SERVER_KEY"On an Astro site the integration reads them for you. getPractice() from @smileline/astro/server reads the server details with your server key (the public ones if the server has none). getPublicPractice() from @smileline/astro/client reads the public details in the visitor's browser, through your site's /_sl/ route, and reads them again after validUntil. From the same import, isOpenNow(location) says whether a location is open at any moment in its own time zone, and withVisitor(bookingUrl) adds the visitor's id to your own booking page's link, so a booking made there counts for the visit. It only does that for your practice's booking page, and only once the script has stored the visitor's id under your consent setting.
Developer SDK
Building a custom site or single-page app? The npm package, @smileline/browser, replaces the snippet rather than joining it, so install one or the other, never both. It has two modes, chosen by what you pass to init.
init({ siteKey, region })(regioniseuorus) loads the Smileline script for your region, exactly as the snippet does: it finds your forms, swaps in call-tracking numbers, counts page views and handles consent, with typed calls on top. An enquiry sent withcaptureLeadis kept in the visitor's browser until Smileline has it, even while the script is still loading or is blocked, so don't retry it yourself. Adddata-sl-formto a form your code sends this way (<form data-sl-form>), or the script captures it too and one enquiry becomes two leads. A strict Content Security Policy needs the same origins as the snippet.init({ siteKey, apiBase }), the original mode, carries the same tracking core (visitor identity, attribution, consent) and turns Snippet installed green on its own, but leaves the two things the snippet does by touching your pages to you:- It does not find your forms, so nothing appears under Website forms by itself. Build each form's capture hook yourself and post to it with
captureLead. - It does not swap in call tracking numbers.
- It does not find your forms, so nothing appears under Website forms by itself. Build each form's capture hook yourself and post to it with
Pick it from the npm SDK tab in step 02 of the install card, which prints the original mode below with your own site key and region already filled in:
npm install @smileline/browserimport { init, captureLead, consent } from "@smileline/browser";
init({ siteKey: "pk_YOUR_SITE_KEY" });init defaults to the EU cell, so US practices pass their regional API base: init({ siteKey: "pk_…", apiBase: "https://api-us.smileline.io" }). The tracking page prints yours, so copying from there is always right.
init(options)— call once; later calls are ignored. Safe to import during server-side rendering (it becomes a no-op).captureLead(token, fields)— submits an enquiry to a form's capture endpoint with the visitor's attribution attached. It never throws; it resolves to{ ok, status, outcome }:okwhen Smileline accepted it,statusthe HTTP status (0when no answer reached the page), andoutcomeas in Send enquiries from your own code. In the original mode it makes one request and reports its real status,429and503included, so code that already retries keeps working; pass{ retry: true }as a third argument to have the SDK keep an undelivered enquiry and send it again on a later page instead (and then don't retry it yourself).consent(state)—"granted","denied", or per-flag, e.g.{ adStorage: true }.visitor()— the visitor ID, ornullbeforeinitcompletes (in the region mode, before the script has loaded).
The 0.1 type names (SmileLineConsent, SmileLineConsentInput, SmileLineInitOptions) still work and are deprecated in favour of Consent, ConsentInput and InitOptions.
The snippet installs the same commands as a global command queue (its first, inline tag), safe to call before the script loads:
sl("consent", "granted");
sl("step", "What is your age?");
sl("captureLead", "YOUR_FORM_TOKEN", { email: "amelia@example.co.uk" });A captureLead queued this way is sent once the script has loaded. To keep an enquiry even when the script is blocked, send it through @smileline/browser or, on an Astro site, @smileline/astro/client.
Community
Share ideas with Smileline and vote on them, follow the roadmap, and chat live with dental teams from every Smileline practice, under a community name of your choice.
Website forms
Build forms in Smileline, confirm the forms detected on your website, and manage every enquiry endpoint from one list.