Installation
Every snippet below uses YOUR_SITE_IDas a placeholder. Grab the real one from a site's Settings page.
Quick start
Data Silo tracks with a single script tag. No cookie banner, no config file, no build step. Paste it before the closing </head> and you're done.
<script defer data-site-id="YOUR_SITE_ID" src="https://yourdomain.com/monitor.js"></script>Plain HTML
Add the snippet to every page, right before </head>:
<!doctype html>
<html>
<head>
<title>My site</title>
<script defer data-site-id="YOUR_SITE_ID" src="https://yourdomain.com/monitor.js"></script>
</head>
<body>...</body>
</html>Next.js
Use next/script in your root layout so it loads once across the App Router:
import Script from "next/script";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<Script
defer
data-site-id="YOUR_SITE_ID"
src="https://yourdomain.com/monitor.js"
/>
</body>
</html>
);
}React (Vite / Create React App)
React has no built-in way to manage <head>, so add the script directly to your index.html:
<head>
...
<script defer data-site-id="YOUR_SITE_ID" src="https://yourdomain.com/monitor.js"></script>
</head>Vue.js
Same idea: add it to the index.html that Vite serves:
<head>
...
<script defer data-site-id="YOUR_SITE_ID" src="https://yourdomain.com/monitor.js"></script>
</head>Nuxt
Add it once, globally, with the built-in useHead composable in app.vue:
<script setup>
useHead({
script: [
{
defer: true,
"data-site-id": "YOUR_SITE_ID",
src: "https://yourdomain.com/monitor.js",
},
],
});
</script>SvelteKit
Add it to src/app.html, which wraps every page:
<head>
...
<script defer data-site-id="YOUR_SITE_ID" src="https://yourdomain.com/monitor.js"></script>
</head>Angular
Add it to src/index.html, which every route shares:
<head>
...
<script defer data-site-id="YOUR_SITE_ID" src="https://yourdomain.com/monitor.js"></script>
</head>WordPress
Use a plugin like Insert Headers and Footers, or paste the snippet directly into your theme's header.php just before <?php wp_head(); ?> closes:
<script defer data-site-id="YOUR_SITE_ID" src="https://yourdomain.com/monitor.js"></script>Shopify
In your theme editor, open theme.liquid and add the snippet right before </head>:
<script defer data-site-id="YOUR_SITE_ID" src="https://yourdomain.com/monitor.js"></script>Webflow
Go to Site settings → Custom code and paste the snippet into Head code, then publish your site:
<script defer data-site-id="YOUR_SITE_ID" src="https://yourdomain.com/monitor.js"></script>Squarespace
Go to Settings → Advanced → Code Injection and paste the snippet into the Header box (this requires a Business or Commerce plan):
<script defer data-site-id="YOUR_SITE_ID" src="https://yourdomain.com/monitor.js"></script>Google Tag Manager
Create a new Custom HTML tag with the snippet below, and set its trigger to All Pages:
<script defer data-site-id="YOUR_SITE_ID" src="https://yourdomain.com/monitor.js"></script>Custom events & goals
Call window.datasilo('track', name, props) from anywhere on the page to record a custom event, then turn it into a goal from a site's Goals & Funnels page.
document.querySelector("#signup-form").addEventListener("submit", () => {
window.datasilo("track", "Signup", { plan: "pro" });
});Revenue attribution
To attribute a Stripe purchase back to a traffic source, fetch the current visitor id and pass it as client_reference_id when you create the Checkout Session:
window.datasilo("getVisitorId", (visitorId) => {
fetch("/create-checkout-session", {
method: "POST",
body: JSON.stringify({ visitorId }),
});
});Then in your own backend, pass that value through to Stripe as client_reference_id, and configure the webhook URL shown on the site's Settings page. Full details are on that page once revenue attribution is enabled.
API, CLI & MCP
Create an API key from a site's Settings page, under API access. The key is shown once, so store it somewhere safe. Every method below (REST, CLI, MCP) uses the same key and the same underlying endpoints — pick whichever fits how you want to pull data out.
REST API
Pass the key as a bearer token. {siteId}is the site's id (visible in its dashboard URL, not the tracking id used in the snippet above).range is optional and defaults to 7d (also accepts 30d or 90d).
curl "https://yourdomain.com/api/v1/sites/YOUR_SITE_ID/stats?range=7d" \
-H "Authorization: Bearer YOUR_API_KEY"Three endpoints are available, all under /api/v1/sites/{siteId}:
/stats— pageviews, visitors, bounce rate, avg. session duration, live visitor count/top-pages— most-viewed pages for the range/revenue— total revenue and revenue by traffic source (requires Stripe revenue attribution)
CLI
Install @data-silo/cli globally, or run it with npx without installing anything:
npm install -g @data-silo/cli
# or: npx @data-silo/cli stats --site YOUR_SITE_IDCommands stats, top-pages, and revenue map directly to the REST endpoints above:
export DATASILO_API_KEY=YOUR_API_KEY
datasilo stats --site YOUR_SITE_ID --range 30dFlags:
--site <id>— required, the site's id (same one used above)--range <range>—7d,30d, or90d(default7d)--api-key/--api-url— override the environment variables for a single call--raw— compact JSON instead of pretty-printed, useful for piping intojq-v,--version/-h,--help
MCP server
Exposes the same three endpoints as tools (get_stats, get_top_pages, get_revenue_by_source) so an MCP client like Claude Desktop can query your analytics directly. Add it to your client config:
{
"mcpServers": {
"datasilo": {
"command": "npx",
"args": ["-y", "@data-silo/mcp"],
"env": {
"DATASILO_API_KEY": "YOUR_API_KEY"
}
}
}
}Both datasilo and datasilo-mcp also honor DATASILO_API_URLas an environment variable if you're self-hosting instead of using https://yourdomain.com.