Install the Peekback widget
One script tag. Add it to your site, and visitors get a button to show you what went wrong.
The snippet
<script src="https://app.peekback.dev/widget/peekback.js"
data-key="pk_live_YOUR_PUBLISHABLE_KEY" async></script>The key is your publishable key. You find the snippet with your own key filled in in the back office, under Install widget. The publishable key is safe in the browser: it can only create reports, it cannot read any.
Add the snippet once per page, right before </body>. The widget loads async. From the moment it loads it captures console errors, failed requests and clicks, and it masks form fields by default.
Plain HTML
Paste the snippet before the closing </body> tag of every page where visitors should be able to report a problem. If your pages share a layout or template file, put it there once.
<body>
<!-- your page -->
<script src="https://app.peekback.dev/widget/peekback.js"
data-key="pk_live_YOUR_PUBLISHABLE_KEY" async></script>
</body>React (Vite, Create React App, any single-page app)
Add a small component that loads the script once, and mount it once at the root of your app.
// PeekbackWidget.jsx
import { useEffect } from 'react';
export default function PeekbackWidget() {
useEffect(() => {
// Already loaded or loading: do nothing.
if (window.Peekback || document.querySelector('script[src*="peekback.js"]')) return;
const script = document.createElement('script');
script.src = 'https://app.peekback.dev/widget/peekback.js';
script.async = true;
script.dataset.key = 'pk_live_YOUR_PUBLISHABLE_KEY';
document.body.appendChild(script);
// No cleanup on purpose: the widget stays for the whole visit.
}, []);
return null;
}// App.jsx
import PeekbackWidget from './PeekbackWidget';
export default function App() {
return (
<>
<PeekbackWidget />
{/* the rest of your app */}
</>
);
}React StrictMode runs effects twice in development. The guard at the top of the effect covers that, so the script is only added once.
The widget stays across client-side route changes. Do not remove the script when the component unmounts.
Next.js
App Router
Add the Script component inside <body> in your root layout.
// app/layout.tsx
import Script from 'next/script';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<Script
src="https://app.peekback.dev/widget/peekback.js"
data-key="pk_live_YOUR_PUBLISHABLE_KEY"
strategy="afterInteractive"
/>
</body>
</html>
);
}Pages Router
Use the same Script component in pages/_app.tsx, next to <Component {...pageProps} />.
WordPress
Option A: a header and footer plugin
Install a plugin that lets you add code to every page, for example WPCode or Insert Headers and Footers. Paste the snippet from the top of this page into its Footer box and save.
Option B: your theme
Add this to the functions.php of a child theme, so a theme update does not remove it. The second function adds the key and async to the script tag.
add_action('wp_enqueue_scripts', function () {
wp_enqueue_script('peekback', 'https://app.peekback.dev/widget/peekback.js', array(), null, true);
});
add_filter('script_loader_tag', function ($tag, $handle) {
if ($handle !== 'peekback') return $tag;
return str_replace(' src=', ' data-key="pk_live_YOUR_PUBLISHABLE_KEY" async src=', $tag);
}, 10, 2);Shopify
- In the Shopify admin, go to Online Store, then Themes.
- Click … next to your theme, then Edit code.
- Open
layout/theme.liquid. - Paste the snippet right before
</body>, and click Save.
Shopify checkout pages do not load theme code, so the widget does not appear there.
Webflow
- Open Site settings, then Custom code.
- Paste the snippet into Footer code and click Save.
- Click Publish.
Custom code needs a paid site plan, and it only runs on the published site, not in the Designer preview.
Options
Set these as data- attributes on the script tag.
| Attribute | What it does |
|---|---|
data-key | Your publishable key. Required. It can only create reports, never read them. |
data-color | Button colour, for example #0f766e. Default #4f46e5. |
data-label | Button text. Default Feedback. |
data-position | right or left. Default right. |
data-mask | Extra CSS selectors to blur, comma separated. They are added to the defaults. |
data-max-seconds | Longest recording allowed, in seconds. Default 180. |
Blur more of the page
Every input, textarea and select is blurred in recordings and screenshots by default. The exceptions are buttons, submit buttons, checkboxes, radio buttons and sliders. Mark anything else that is sensitive, like balances, or keep a field visible on purpose.
<span data-peekback-mask>€ 12,480.22</span>
<!-- or keep a field visible on purpose -->
<input name="search" data-peekback-unmask>Identify your users (optional)
Logged-in users skip the email field, and their account details show up next to every report.
<script>
// Optional: tell Peekback who is logged in
window.addEventListener("load", function () {
Peekback.identify({ name: "Sara Petrović", email: "sara@example.com" });
Peekback.setMetadata({ plan: "Premium", accountId: "acc_123" });
});
</script>In a single-page app, the script may not be there yet when your code runs. Call these once the script has loaded, in its onload handler:
const script = document.createElement('script');
script.src = 'https://app.peekback.dev/widget/peekback.js';
script.async = true;
script.dataset.key = 'pk_live_YOUR_PUBLISHABLE_KEY';
script.onload = () => {
window.Peekback.identify({ name: user.name, email: user.email });
window.Peekback.setMetadata({ plan: user.plan, accountId: user.accountId });
};
document.body.appendChild(script);If the widget does not show
- The script tag has
data-key, and its value is the publishable key, not the secret key. - If your site sends a Content-Security-Policy header, it must allow
script-src https://app.peekback.devandconnect-src https://app.peekback.dev. - Ad blockers and privacy extensions can block the script. Try in a private window with extensions off.
- The browser console (Network tab) shows whether
peekback.jsloaded. A blocked request there points to one of the causes above.
Next
To read reports from your own systems, see the API reference.