Want your supporters' details to appear on your NationBuilder donation form as soon as they tap a link from CallHub? Add a short script to your donation page template once, and the form fills itself in. This article is for the person who manages your NationBuilder website, and it is the setup step for pre-filled donation links in CallHub.
CallHub can add each contact's name, email, mobile and address to their donation link. NationBuilder does not read those details by default, so the form still opens empty. The script in this article closes that gap. It reads the details from the link and places them in the matching form fields.
Here is what you can expect:
- A form that is ready when the supporter taps. Name, email, mobile, address, city and zip are filled in before they see the page.
- Fewer people giving up on a phone. Typing on a small screen is where many donors drop off. Pre-fill removes most of it.
- One setup for every campaign. You add the script to the page once. Every CallHub campaign that links to this page can then use pre-fill.
- Nothing changes for other visitors. If a link has no details in it, the form opens as usual. Supporters can still edit any pre-filled field.
Before you start
- Access: you need to sign in to the NationBuilder control panel for the website that holds your donation page, with permission to edit page templates.
- A Donation (v2) page: legacy Donation pages use different field names, so this script does not fill them.
- Time: about 10 minutes.
- Where this fits: do this before you turn on pre-fill in a CallHub campaign. See Pre-fill NationBuilder donation links with each supporter's details.
⚠ Use a Donation (v2) page, not a legacy Donation page. Why: NationBuilder hides legacy Donation pages from January 28, 2027, and their field names differ, so the script cannot fill them.
Add the pre-fill script to your donation page
- Sign in to the NationBuilder control panel. [Screenshot: NationBuilder control panel after sign in | filename: nationbuilder_control-panel_home.png | alt: NationBuilder control panel home screen]
- Open the website that holds your donation page. [Screenshot: The list of NationBuilder websites with the right site selected | filename: nationbuilder_site_select.png | alt: List of NationBuilder websites with one site highlighted]
- Open your donation page. Check that it is a Donation (v2) page. [Screenshot: The Pages list with the Donation (v2) page highlighted | filename: nationbuilder_donation-v2_page.png | alt: NationBuilder Pages list with the Donation v2 page highlighted]
- On the page, go to the Template tab. [Screenshot: The Template tab on the donation page | filename: nationbuilder_donation-page_template-tab.png | alt: Template tab highlighted on a NationBuilder donation page]
- Click Create a custom template. [Screenshot: The Create a custom template button | filename: nationbuilder_template_create-custom.png | alt: Create a custom template button highlighted]
- Scroll to the bottom of the template. Paste the full script below, including the opening and closing
<script>tags.
<script>
document.addEventListener('DOMContentLoaded', function () {
var params = new URLSearchParams(window.location.search);
var fields = {
first_name: 'donation[first_name]',
last_name: 'donation[last_name]',
email: 'donation[email]',
mobile: 'donation[billing_address_attributes][phone_number]',
address: 'donation[billing_address_attributes][address1]',
city: 'donation[billing_address_attributes][city]',
zip: 'donation[billing_address_attributes][zip]'
};
Object.keys(fields).forEach(function (key) {
var value = params.get(key);
var input = document.querySelector('[name="' + fields[key] + '"]');
if (!value || !input) return;
input.value = value;
input.dispatchEvent(new Event('input', { bubbles: true }));
input.dispatchEvent(new Event('change', { bubbles: true }));
});
});
</script>[Screenshot: The script pasted at the bottom of the template | filename: nationbuilder_template_paste-script.png | alt: Template editor with the pre-fill script pasted at the bottom]
- Save the template. [Screenshot: The Save button in the template editor | filename: nationbuilder_template_save.png | alt: Save button highlighted in the template editor]
- Open your donation page with test values added to the address. For example:
https://your-site.example/donate?first_name=Jane&last_name=Smith&email=jane%40example.com&zip=94105Replace the first part with the address of your own donation page. [Screenshot: The donation page opened with test values, fields filled in | filename: nationbuilder_donation-page_prefill-test.png | alt: Donation form with first name Jane, last name Smith, email and zip already filled in]
✓ In the test address, write the @ sign in an email as %40. CallHub does this for you in real campaign links.
What the script fills in
The script matches each detail in the link to a field on your Donation (v2) form.
| Detail in the link | Form field it fills |
|---|---|
first_name |
First name |
last_name |
Last name |
email |
|
mobile |
Phone number (billing) |
address |
Address line 1 (billing) |
city |
City (billing) |
zip |
Zip (billing) |
What works without a template change
You do not need the script to pre-fill the amount. NationBuilder supports it on Donation (v2) pages. For example, ?amount=50 selects the matching preset button, or fills the Other amount if no preset matches.
Notes and limits
ⓘ The script fills a field only when the link has a value for it and the form has that field. Anything else is skipped, and the page still opens normally.
ⓘ Pre-filled details sit in the link address. Why: a link made for one supporter carries that person's details, so share each link only with the person it was made for.
✓ Keep a copy of the script in a shared document. If your team recreates the donation page later, you can paste it in again.
FAQs
Why is my form not filling in?
Check that the page is a Donation (v2) page, that the script is at the bottom of the template and was saved, and that the field exists on your form. Legacy Donation pages are not supported.
Do I need this script to pre-fill the amount?
No. The amount works on Donation (v2) pages without any template change. See "What works without a template change" above.
Can supporters change the pre-filled details?
Yes. The script only fills the fields when the page opens. Supporters can edit any field before they give.
Do I need to repeat this for every campaign?
No. Add the script once to the donation page. Any CallHub campaign that links to this page can then use pre-fill.
Comments
0 comments
Please sign in to leave a comment.