When you serve a form via your own custom domain, you can inject custom JavaScript that runs inside the form page itself — no embed or popup involved. Use it to prefill fields from an API call, read values entered by the respondent, or read previously saved answers from the browser. Paste your code into the Code injection box of your custom domain settings.Documentation Index
Fetch the complete documentation index at: https://developers.tally.so/llms.txt
Use this file to discover all available pages before exploring further.
Wait for the DOM
Wrap your code in aDOMContentLoaded event handler so the form has finished rendering
before you query its inputs.
Read an input element
Each block in a Tally form has a stable UUID — you can find it by inspecting the rendered form in your browser’s DevTools. Pass that UUID todocument.getElementById() to get the
underlying input element.
Set a value on an input element
The form is a React app, so simply assigning to.value won’t update its state — React’s
synthetic event system needs to see a real input event. The snippet below uses the native
setter and dispatches a bubbling input event so React picks the change up.
Read previously entered answers
Tally persists in-progress answers to the browser’slocalStorage under a key derived from
the form ID. You can read them out at any time:
Events
Code injection has access to the same JavaScript events as embeds and popups, dispatched asCustomEvents on window rather than as postMessage payloads. See
Events for the full payload reference and listener patterns.