Skip to content

Script tag & web component

<page-pal> works in plain HTML and in every framework that renders HTML: Svelte, Angular, Solid, Astro, Rails, Django templates, WordPress.

The script-tag build registers the element for you:

<script src="https://unpkg.com/pagepal@1"></script>
<page-pal watch="form#signup" requests character="cat"></page-pal>
import 'pagepal/element';

Then use <page-pal> in your templates. In Angular, add CUSTOM_ELEMENTS_SCHEMA to the component that uses it.

AttributeExampleOption
charactercharacter="ghost"character
positionposition="bottom-left"position (inline renders inside the element)
size, offsetsize="64"size, offset
colorcolor="#e8590c" or color="auto"color
watchwatch="form#signup, form#login"watch (any CSS selector list)
storage-keystorage-key="docs-pal"storageKey
analytics-endpointanalytics-endpoint="/api/ux"adds the analytics plugin

On/off attributes: requests, errors, interactive, keyboard, remember, scroll, network, dark-mode, idle, password, frustration, dead-clicks, avoid, copy, welcome-back. Present means on; ="false" means off:

<page-pal requests errors idle="false" dark-mode="false"></page-pal>

Changing any attribute recreates the pal with the new options. Removing the element removes the pal.

const el = document.querySelector('page-pal');
el.addEventListener('pagepal:ready', (event) => {
const pal = event.detail;
pal.on('frustration', (d) => console.log(d.kind));
});
el.pal?.react('cheer'); // once it's connected

The pal in the corner is pagepal itself.