cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD, a visitors card on quillbook.com (320 × 176 px), and are the exact code the dashboard produces for it.
Your style, theme, accent and label live on CrispStats, not in the code: change them in the widget and every copy follows within 3 minutes, whatever the form. Only a change of layout or size needs new code, because the code reserves the box.
Script and element
Paste both lines where the widget should show:<crispstats-widget> elements as you like. Extra copies of the script do nothing. The style attribute reserves the widget’s exact box before the data arrives, so your page does not move when it loads.
Two optional attributes on the element:
The widget draws inside a closed shadow root, so your page’s CSS cannot break it and its CSS cannot leak into your page. It inherits your page’s font. A pill keeps the width the code reserves and sits at the start of it; to centre it, set
text-align: center on the crispstats-widget element. To adjust it from your own stylesheet:
The parts
surface, label, value, footer, dot, gauge and link can be styled with crispstats-widget::part(...). The Ahrefs line on a Domain Rating widget ignores attempts to hide it.
iframe
?theme=light or ?theme=dark to the src to fix it, or ?l=de to set the language.
The iframe is also the form to use on a page with a strict Content Security Policy: it runs no script on your page, so the policy only has to allow the frame. If you set Allowed sites on the widget, the iframe can only be shown on those sites.
Notion
In Notion, type/embed, choose Embed and paste the link from the Notion tab:
README and Markdown
GitHub and most Markdown renderers show images, not scripts. The README tab gives an SVG image, wrapped in a link, that shows the light or the dark version to match GitHub’s theme:Markdown
Where only Markdown is allowed, such as some wikis, forums and docs tools, the Markdown tab gives the image as a Markdown link. Markdown cannot offer a light and a dark image, so this form cannot follow a site’s own theme switch, such as GitHub’s: with the theme on Auto the image follows the reader’s system setting, and with Light or Dark it stays that way.Caching and the hidden state
GitHub serves README images through its own image proxy, which caches them for a few minutes, so an image lags slightly behind the script. An image cannot hide like the script does: when a widget has nothing to show yet, the image is a transparent pixel titled “Nothing to show yet”, never a broken image. Add?theme=light, ?theme=dark or ?theme=auto to an image URL to fix its theme; without it the image uses the widget’s Theme setting.
Shields badges
If your README already uses shields.io badges, the shields tab gives one that matches them:visitors 30d and 48.2k, in your accent colour. A widget with nothing to show yet reads not yet in grey. For a Domain Rating widget the label is always “Domain Rating by Ahrefs”, linked to Ahrefs, followed by our credit:
React
There is no package to install. Load the script once and use the element where the widget should show:next/script; in another React app, add the script tag to your HTML once. Put the type declaration in its own file, such as crispstats.d.ts, so TypeScript accepts the custom element. Keep its export {} line: it makes the file add to React’s types instead of replacing them.
First-party proxy
If you serve the CrispStats script through a proxy on your own domain, the same rule serves widgets too: every widget path is also answered under/p/. With the proxy path /k3x9qe, load the script from /k3x9qe/w/v1/loader.js instead of https://in.crispstats.com/w/v1/loader.js. The script then fetches widget data through the same path. Widget paths contain neither “track” nor “analytics”, so content blockers leave them alone even without a proxy.
Site builders
The Code section has a Where are you adding it? menu with one line for each:
On Notion use the iframe link; on GitHub use the README form.
Content Security Policy
If your site sets a Content Security Policy, allow https://in.crispstats.com in script-src and connect-src, or use the iframe. In the policy, that is:img-src https://in.crispstats.com. The iframe runs no script on your page, so it needs only frame-src https://in.crispstats.com. See Content Security Policy for the rest of the CrispStats entries.
Try it with a demo widget
The public demo’s widgets can be embedded by anyone, with sample numbers. Paste this into any HTML page to see a widget working before you create your own:When a widget does not show
Nothing appears where I pasted the code
Nothing appears where I pasted the code
Open the browser’s network tab and find the request to
/w/v1/d. A token missing from the answer, or a 404, means the widget is paused, deleted, over your plan’s limit, has nothing to show yet, or is not allowed on this site by Allowed sites. The console also says crispstats: widget <token> is not available. Check the widget in Settings, Sharing and widgets: its row says where it was last seen.The widget shows on one page but not another
The widget shows on one page but not another
The script must be on every page that has a widget. If Allowed sites is set, the page’s host name must match an entry:
example.com covers that host only, so add www.example.com too or use *.example.com, which covers example.com and every subdomain. A page that hides its address, such as a sandboxed frame or a page opened from a file, cannot show a script widget with Allowed sites set; use the iframe there.The browser console mentions a Content Security Policy
The browser console mentions a Content Security Policy
Add the entries under Content Security Policy, or use the iframe.
The README image did not change after I edited the widget
The README image did not change after I edited the widget
GitHub’s image proxy keeps a copy for a few minutes. Reload later. Editing the widget never changes its image URL.
Space is reserved but stays empty
Space is reserved but stays empty
The script reserves the box, then removes it as soon as the answer says the widget has nothing to show: a live count of 0, a figure of 0, or a Domain Rating that has not been read yet. If the collector cannot be reached at all, the script removes the box after 8 seconds and leaves nothing broken behind.
Next steps
Widget JSON
The data behind every widget, and the endpoints.
Brand badge
“Powered by CrispStats” without an account.
Widgets
Kinds, styles, limits and privacy.