@siteline/core SDK. The edge function proxies the request transparently, so there is zero impact on site performance.
Prerequisites
- A Siteline website key
- A Netlify site with Edge Functions enabled
Netlify Edge Functions are available on all plans, including the free tier. See Netlify Edge Functions for details.
Setup
Add the edge function
Create an The function imports
edge-functions directory in the root of your Netlify project and copy siteline.ts into it:@siteline/core via an ESM URL (https://esm.sh/@siteline/[email protected]) — no npm install is needed since Netlify Edge Functions run on Deno.Set your website key
Open Optionally configure
edge-functions/siteline.ts and set the SITELINE_WEBSITE_KEY constant at the top of the file:SITELINE_ENDPOINT and SITELINE_DEBUG.Configure Netlify routes
Create or update This routes every incoming request through the Siteline edge function.
netlify.toml in your project root:netlify.toml
How it works
The edge function runs as middleware on every matched request:- A visitor (or AI bot) makes a request to your Netlify site
- The edge function calls
context.next()to forward the request to your origin - Tracking data (
url,method,status,duration,userAgent,ref,ip,acceptHeader) is sent to Siteline asynchronously via fire-and-forget - The response is returned to the visitor unmodified
500 before re-throwing the error. The SDK initializes lazily on the first request and reuses the instance for subsequent calls.
View the full source on GitHub.
Configuration
Your Siteline website key. If empty, tracking is disabled and a warning is logged to the console.
Siteline intake endpoint. Defaults to
https://api.siteline.ai/v1/intake/pageview.Enables debug logging. When
true, errors in the edge function are logged to the console.Troubleshooting
No visits appearing in Siteline
No visits appearing in Siteline
Verify
SITELINE_WEBSITE_KEY is set to a valid key in edge-functions/siteline.ts. Confirm netlify.toml routes /* to function = "siteline".Edge function does not run on requests
Edge function does not run on requests
Ensure
[build] edge_functions = "edge-functions" is present in netlify.toml and that the file exists at edge-functions/siteline.ts.Will this slow down my site?
Will this slow down my site?
No. Tracking is fire-and-forget — the tracking call is not awaited and never blocks the response.
Do I need to install any npm packages?
Do I need to install any npm packages?
No. The edge function imports
@siteline/core via an ESM URL, which Netlify’s Deno-based runtime resolves automatically.