> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crispstats.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> CrispStats is a hosted, privacy-first web analytics product. It has no self-hosted edition, no session replay, no heatmaps, no A/B testing, no mobile SDKs and no data import except a site's history from a Plausible export (Settings, Import and export).
> The script global is crispstats(...), site keys start with cs_pk_ and secret API keys start with cs_sk_. The script is served from https://in.crispstats.com/d.js and the REST API lives at https://crispstats.com/api/v1.
> There is no npm package to install. Integrations copy the script tag, the queue stub, crispstats.d.ts and proxy code from these docs or from Settings, Tracking code in the dashboard. A first-party proxy forwards one path of the site to https://in.crispstats.com/p/ and forwards only content-type, user-agent, accept-language, referer, origin, if-none-match and x-forwarded-for, never cookies.

# Embed a widget: script, iframe, README, Notion and React

> Every way to paste a CrispStats widget: the script and element, an iframe for Notion and strict pages, a dark-mode-aware README image, a shields.io badge, React and Next.js, a first-party proxy, and notes for each site builder.

Every widget can be pasted in several forms. The **Code** section of a widget, in **Settings**, **Sharing and widgets**, fills in your widget's token and the right sizes; copy from there. The examples on this page use the sample token `cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD`, a visitors card on `quillbook.com` (320 × 176 px), and are the exact code the dashboard produces for it.

| Form | Use it for | Updates live | Tab |
| - | - | - | - |
| [Script and element](#script-and-element) | Your own site and every site builder that accepts HTML | Yes | **HTML** |
| [iframe](#iframe) | Notion, pages with a strict Content Security Policy, builders that strip scripts | Yes | **iframe**, **Notion** |
| [Image](#readme-and-markdown) | GitHub and other READMEs that accept HTML | Every few minutes | **README** |
| [Markdown image](#markdown) | Places that take Markdown but no HTML | Every few minutes | **Markdown** |
| [shields.io](#shields-badges) | READMEs that already use shields.io badges | Every few minutes | **shields** |
| [React](#react) | Apps built with React or Next.js | Yes | **React** |
| [JSON](https://docs.crispstats.com/share/widgets/json-api.md) | Drawing the widget yourself | When you fetch | **JSON** |

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:

```html wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
<script async src="https://in.crispstats.com/w/v1/loader.js"></script>
<crispstats-widget widget="cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD" style="display:inline-block;vertical-align:middle;width:320px;height:176px"></crispstats-widget>
```

The script loads once per page: paste it once, then as many `<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:

| Attribute | Values | Default |
| - | - | - |
| `theme` | `auto`, `light`, `dark` | The widget's **Theme** setting. `auto` follows the page under the widget, not the reader's system setting: see [Theme and accent](https://docs.crispstats.com/share/widgets.md#theme-and-accent). |
| `lang` | A language tag such as `de` or `fr-CA` | English. Numbers and dates follow it; the words stay in English in this version. The page's own `lang` is not used. |

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:

| Custom property on `crispstats-widget` | Changes |
| - | - |
| `--cs-widget-font` | The font family |
| `--cs-widget-radius` | The corner radius |
| `--cs-widget-accent` | The accent colour |

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

```html wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
<iframe src="https://in.crispstats.com/w/v1/f/cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD" title="Visitors on quillbook.com" width="320" height="176" loading="lazy" style="border:0;background:transparent;color-scheme:normal"></iframe>
```

The iframe holds the same widget, with its first data already inside, so it shows without a second request. Links inside it open in the same tab, replacing your page, never a popup. The iframe cannot see your page, so with the theme on Auto it follows the reader's system setting; add `?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:

```text wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
https://in.crispstats.com/w/v1/f/cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD
```

Resize the embed block to the widget's size.

## 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:

```html wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
<a href="https://crispstats.com/share/quillbook"><picture><source media="(prefers-color-scheme: dark)"><img alt="Visitors on quillbook.com" src="https://in.crispstats.com/w/v1/i/cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD.svg?theme=light" width="320" height="176"></picture></a>
```

The link goes to your [public dashboard](https://docs.crispstats.com/share/public-dashboard.md) when it is on, and to the CrispStats home page otherwise. A revenue or sales widget links to its [proof page](https://docs.crispstats.com/share/widgets/revenue.md#the-proof-page) instead:

```html wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
<a href="https://crispstats.com/verified/cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD"><picture><source media="(prefers-color-scheme: dark)"><img alt="Verified MRR for quillbook.com" src="https://in.crispstats.com/w/v1/i/cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD.svg?theme=light" width="320" height="176"></picture></a>
```

For a Domain Rating widget the image links to Ahrefs, as Ahrefs' licence asks, and our credit is a separate link after it:

```html wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
<a href="https://ahrefs.com/"><picture><source media="(prefers-color-scheme: dark)"><img alt="Domain Rating of quillbook.com, by Ahrefs" src="https://in.crispstats.com/w/v1/i/cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD.svg?theme=light" width="320" height="176"></picture></a>
<a href="https://crispstats.com/share/quillbook">Powered by CrispStats</a>
```

### 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.

```md wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
[![Visitors on quillbook.com](https://in.crispstats.com/w/v1/i/cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD.svg)](https://crispstats.com/share/quillbook)
```

A Domain Rating widget gives two links in a row, the image to Ahrefs and our credit:

```md wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
[![Domain Rating of quillbook.com, by Ahrefs](https://in.crispstats.com/w/v1/i/cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD.svg)](https://ahrefs.com/) [Powered by CrispStats](https://crispstats.com/share/quillbook)
```

### 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](https://shields.io) badges, the **shields** tab gives one that matches them:

```md wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
[![Visitors on quillbook.com](https://img.shields.io/endpoint?url=https%3A%2F%2Fin.crispstats.com%2Fw%2Fv1%2Fs%2Fcs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD)](https://crispstats.com/share/quillbook)
```

The badge shows the widget's badge text, such as `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:

```md wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
[![Domain Rating by Ahrefs](https://img.shields.io/endpoint?url=https%3A%2F%2Fin.crispstats.com%2Fw%2Fv1%2Fs%2Fcs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD)](https://ahrefs.com/) [Powered by CrispStats](https://crispstats.com/share/quillbook)
```

## React

There is no package to install. Load the script once and use the element where the widget should show:

```tsx wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
// once, e.g. in app/layout.tsx
import Script from "next/script";
<Script src="https://in.crispstats.com/w/v1/loader.js" strategy="afterInteractive" />

// where it shows
<crispstats-widget widget="cs_wd_7Hq2Lx9PzK4mVt8RbN3cW1yD" style={{ display: "inline-block", verticalAlign: "middle", width: 320, height: 176 }} />

// types (crispstats.d.ts). The export makes the file a module, so this adds to React's types instead of replacing them.
export {};
declare module "react" { namespace JSX { interface IntrinsicElements { "crispstats-widget": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & { widget: string; theme?: "auto" | "light" | "dark"; lang?: string } } } }
```

The first part is for Next.js and uses `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](https://docs.crispstats.com/tracking/proxy.md), 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:

| Builder | How |
| - | - |
| WordPress | Add a Custom HTML block where the widget should show and paste the HTML code. |
| Webflow | Drag an Embed element onto the page and paste the HTML code. |
| Framer | Insert an Embed component, choose HTML and paste the HTML code. |
| Shopify | In the theme editor, add a Custom Liquid section and paste the HTML code. |
| Ghost | Add an HTML card to the post or page and paste the HTML code. |
| Carrd | Embed element, on Carrd Pro. On other plans use the image from the README tab. |

On Notion use the [iframe link](#notion); on GitHub use the [README form](#readme-and-markdown).

## Content Security Policy

If your site sets a Content Security Policy, allow [https://in.crispstats.com](https://in.crispstats.com) in script-src and connect-src, or use the iframe. In the policy, that is:

```text wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
script-src https://in.crispstats.com
connect-src https://in.crispstats.com
```

If your policy limits images, README-style images also need `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](https://docs.crispstats.com/help/content-security-policy.md) 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:

```html wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
<script async src="https://in.crispstats.com/w/v1/loader.js"></script>
<crispstats-widget widget="cs_wd_demoVisitorsCard00000000" style="display:inline-block;vertical-align:middle;width:320px;height:176px"></crispstats-widget>
```

## When a widget does not show

> [accordion] 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.

> [accordion] 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.

> [accordion] The browser console mentions a Content Security Policy
>
> Add the entries under [Content Security Policy](#content-security-policy), or use the [iframe](#iframe).

> [accordion] 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.

> [accordion] 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

> [card] [Widget JSON](https://docs.crispstats.com/share/widgets/json-api.md)
>
> The data behind every widget, and the endpoints.

> [card] [Brand badge](https://docs.crispstats.com/share/widgets/brand-badge.md)
>
> "Powered by CrispStats" without an account.

> [card] [Widgets](https://docs.crispstats.com/share/widgets.md)
>
> Kinds, styles, limits and privacy.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.