forms
A form_submit event with the form id and the path it posts to.
import { forms } from "@spoar/sdk/plugins";import { createAnalytics } from "@spoar/sdk";
import { forms } from "@spoar/sdk/plugins";
export const analytics = createAnalytics({
project: "example.com",
key: "pk_...",
endpoint: "/_ra",
plugins: [forms()],
});Options
forms() takes no options.
Sends
| Event | Props |
|---|---|
form_submit | { form: string, action: string } |
formis the form'sid, else itsnameattribute, else an empty string.actionis the path of the form'sactionURL, or of the current page when the form has none. The host and query string are left out.
Behaviour
- One
submitlistener ondocument, in the capture phase, so every form on the page counts, including forms added later. - Nothing from the fields is read: no values, names or counts.
- The event is sent when the browser fires
submit, whether or not your own handler then cancels it or the request fails. A form the browser's built-in validation blocks fires nosubmitand sends nothing.
In reports
breakdown/prop:form with filter[event]=form_submit counts submissions per form.