JavaScript SDK
The easiest way to capture leads on your website: include the SDK and bind it to an existing HTML form. The SDK validates the input, sends it through the REST API and reports success or failure to your callbacks.
Setup
<script src="https://app.advision360.de/sdk/app.min.js"></script>
<script>
Advision.configure({ apiKey: 'YOUR_API_KEY' })
Advision.bindForm('#lead-form')
</script>
| Function | Description |
|---|---|
Advision.configure(options) | Sets the lead key. Call once per page, before binding a form. |
Advision.bindForm(selector, options?) | Intercepts the form submission and sends the data as a lead. |
The SDK automatically adds the address of the current page to every lead (_meta.url). It is shown as the origin in the lead details.
Form fields
The SDK reads inputs by their name attribute.
name | Required | Notes |
|---|---|---|
firstName | yes | Max 100 characters. |
lastName | yes | Max 100 characters. |
email | email or phone | Valid email address, max 255 characters. |
phone | email or phone | Max 50 characters. |
source | no | Origin of the lead, see allowed values. |
notes | no | Free text stored on the lead. |
additionalFields.<key> | no | Custom values, see Custom fields. |
Any other form field is also collected into additionalFields, with its name as the key. The fields _key, _redirect and _meta are ignored.
bindForm options
<script>
Advision.configure({ apiKey: 'YOUR_API_KEY' })
Advision.bindForm('#lead-form', {
onSuccess: () => {
window.location.href = '/thank-you'
},
onError: (error) => {
document.querySelector('#form-error').textContent = error.error
},
additionalData: { campaign: 'spring-2026' },
resetOnSuccess: true,
})
</script>
| Option | Type | Description |
|---|---|---|
onSuccess | (response) => void | Called after a successful submission. |
onError | (error: { error: string }) => void | Called on validation, network or API errors. error.error contains the message. |
additionalData | object | Extra values added to additionalFields of every lead, e.g. a campaign identifier. |
resetOnSuccess | boolean | Clear the form after success. Default: true. |
bindForm returns a function that removes the binding again. If no form matches the selector, bindForm returns undefined and logs a warning to the console.
:::info Redirect after submission
The SDK does not send the _redirect field. Redirect in onSuccess instead, as shown above.
:::
Programmatic API
To send a lead without a form, use submitLead. validate checks data without sending it.
try {
await Advision.submitLead({
firstName: 'Max',
lastName: 'Mustermann',
email: 'max@example.com',
additionalFields: { budget: '5000' },
})
} catch (error) {
console.error(error.message)
}
const { valid, errors } = Advision.validate({
firstName: 'Max',
lastName: '',
email: 'max@example.com',
})
| Function | Description |
|---|---|
Advision.submitLead(data) | Validates and sends a lead. Returns a promise that rejects with an Error on failure. |
Advision.validate(data) | Returns { valid, errors }. Possible keys in errors: firstName, lastName, email, contact (neither email nor phone given). Messages are in English. |
Advision.getMeta() | Returns { url } with the address of the current page, as sent in _meta.url. |
Custom API host
By default the SDK sends to the host app.min.js was loaded from. Set endpoint to choose the host yourself, e.g. when you host the SDK file on your own server:
Advision.configure({
apiKey: 'YOUR_API_KEY',
endpoint: 'https://app.advision360.de',
})