Skip to content
Widget

Control the widget from your code

The widget has a small JavaScript API, window.PageTruth, and a handful of data attributes for the script tag.

3 min readUpdated 18 Oct 2026

Open it from your own UI

PageTruth.open();                              // open the widget
PageTruth.close();                             // close it
PageTruth.toggle();                            // open or close
PageTruth.ask('How do I invite my team?');     // open and ask a question

Use these from a Help menu item, a tooltip or an empty state: "Not sure what this does? Ask."

Calls made before the script loads

The script loads asynchronously. To call it straight away, set up a queue first; it runs as soon as the widget is ready:

window.PageTruth = window.PageTruth || { q: [] };
PageTruth.q.push(['ask', 'How do I invite my team?']);

Data attributes

Add these to the script tag to change one page without touching your dashboard settings:

Attribute Values What it does
data-key your pk_… key Required. Which knowledge base answers
data-layout panel, bubble, modal, inline Overrides the layout
data-position right, left Overrides the corner
data-open true Opens the widget when the page loads
data-launcher false Hides the launcher, for your own button
data-push true, false Side panel only: push the page aside or cover it

Inline mount

For the Inline layout, add an element where the widget should render. The script mounts into every one on the page:

<div data-pagetruth></div>
<script src="https://pagetruth.com/widget.js" data-key="pk_…" data-layout="inline" async></script>

How it stays out of your way

The widget runs inside an iframe served by PageTruth. Your page's styles and scripts can't reach it and it can't reach them. It has no dependencies and sets no cookies.

From your backend

To answer questions from your own server instead, use the Answer API.

Was this helpful?