Page feedback widget
The feedback widget asks readers "Was this page helpful?" at the bottom of each page. It is off by default. DocsLit does not store responses. It forwards each one to places you control: your own endpoint, your analytics provider, or a browser event.
Turn it on
Customize the question, and send responses to an endpoint:
http(s) endpoint that receives a JSON POST for each response. Other values are ignored.Hide the widget on one page with frontmatter:
How readers use it
A reader clicks Yes or No. Yes shows a thank-you message. No opens an optional comment box with Send and Skip buttons. The widget remembers the answer in the reader's browser, per page, version and locale, so it shows the thank-you message on later visits instead of asking again.
What gets sent
Each response sends a payload like this:
version appears on versioned sites. comment is sent only with a written comment, in a second request after the first one that carried helpful.
To your endpoint, DocsLit sends a POST with Content-Type: application/json, without cookies, and ignores the response. The endpoint must allow cross-origin requests from your docs site.
Analytics and events
When you configure no url, the widget is still useful if you use an analytics provider or listen for the event. On the Yes or No click, DocsLit calls whichever of these is present on the page:
| Provider | Call |
|---|---|
| Plausible | plausible('Page Feedback', { props: { page, helpful } }) with helpful set to yes or no |
| Google Analytics 4 | gtag('event', 'page_feedback', { page_path, helpful }) |
| PostHog | posthog.capture('page_feedback', { page, helpful, version }) with a boolean helpful |
| Fathom | fathom.trackEvent('page feedback yes: <page>') |
The widget also fires a docslit:feedback event on window for every response and every comment. Its detail is the payload above. Use it to send data anywhere:
Add the script with the head option. The analytics presets in docslit.json load the provider scripts above.
feedback: true and no url, no analytics provider and no listener, a reader's click is saved only in their own browser. Configure at least one destination before you turn the widget on.