Self-host & build › Developers › Embed and widget code
Embed and widget code
Every way to add a Looona form to a site, the embed script's attributes, and how to say who is answering.
The Share window writes this code for you. This page is for the developer who pastes it, or wants to go further. See Share or embed a form.
Below, <id> is the end of the form's link, /f/<id>, and https://feedback.acme.com stands for your Looona address. On looona.com, it's https://forms.looona.com.
The ways to add a form
| Way | For |
|---|---|
| Link | An email, a support macro, a button on your site. |
| Iframe | A page that can't run scripts. Fixed height. |
| Embed | The form in the page, as tall as its content. |
| Widget | A button in a bottom corner of every page, that opens the form. |
| Your own button | A link or button your site already has. |
| QR code | A screen or a print. |
None of them needs a key: the link is the only identifier.
Iframe
<iframe src="https://feedback.acme.com/f/<id>" title="Feedback" width="100%" height="600" style="border:0"></iframe>
The embed script
The embed, the widget and your own button use one script. Paste it once per page:
<script src="https://feedback.acme.com/embed/v1.js" async></script>
Then add the element for the way you want.
Embed, the form in the page, as tall as its content:
<div data-looona-form="<id>"></div>
Widget, a button in a bottom corner:
<div data-looona-widget="<id>" data-label="Feedback"></div>
Your own button: any element opens the form, centred, with no floating button:
<a href="https://feedback.acme.com/f/<id>" data-looona-open="<id>">Feedback</a>
The script works with several forms on a page, and with elements added after it ran, as React or Vue do. It never changes: the snippet you paste keeps working.
Widget attributes
| Attribute | What it does |
|---|---|
data-label | The button's text, and the window's title until the form loads. "Feedback" by default. |
data-color | The button's colour, any CSS colour. The text turns black or white, whichever reads better. |
data-position="left" | The bottom-left corner. Bottom right by default. |
data-icon-only | A square button with the icon only. The label stays its accessible name. |
data-window="modal" | Opens the form centred, over the page, in place of the small window above the button. For long forms. |
On a screen 480 px wide or less, the form opens as a sheet from the bottom.
Who is answering
When the form's Settings turn on Let your site say who is answering, add who is answering to the element:
<div data-looona-widget="<id>" data-user="[email protected]" data-group="Fernhill Studio"></div>
With a link, add ?user= and ?group= instead. Anyone can change these values: use them to sort responses, never to trust who sent them.
The page's address
When the form collects Page it was opened from, the script sends the page's address without its query string. Add data-full-url to send the query string too. It's off by default: query strings can carry tokens.
Capture this page
The script lets the form capture the page it's on: a File upload question then offers Capture this page. See Files and screenshots. The browser always asks the person first.
A site can forbid it in its Permissions-Policy header:
Permissions-Policy: display-capture=()
The button then doesn't show, and choosing a file still works.
QR code
<img src="https://feedback.acme.com/f/<id>/qr.svg" alt="Scan to give feedback" width="200" height="200">
Add ?download to the address to save it as a file.
Security
The form runs in an iframe from your Looona, so it can't clash with your styles, and your page never sees the answers. A closed form, or one whose link was replaced, shows a closed or not-found page where it's embedded.