Using the Snippet Feature for Conditional Content

You can customize contribution forms to display personalized content, like a donor’s name, to try and engage more directly with supporters and encourage them to give. You can do that by adding what we call “snippets” of code to your form’s title and text in the form editor! Snippets let your form show content that varies depending on the donor or specific link parameters.

The most popular snippet is the donor name snippet. To use this one, head to the “Title, ask, and URL” tab of the form editor where you can use a snippet in either the “Title” or “Donation ask” sections (or both!). Wherever you’d like to include a donor’s name, type out {first_name | Supporter} or {last_name | Supporter}, which will cause the form to show the first or last name of any donor that our system recognizes.

If someone is a first-time donor or doesn’t have their browser’s cookies enabled, then the form instead refers to the default value included in the second half of the snippet — in this case, “Supporter.”  

The name snippet is currently the only one that works simply by being entered into your form’s title or text, and is also the only snippet that will pull data from ActBlue. When using snippets for anything besides names, in addition to inserting the code in the text you will need to attach a parameter to the form’s URL to specify the content a donor should see. It’s important to note that for any custom snippet, you can label the first half of the snippet whatever you would like. However, you must match the URL parameter to what you choose for the snippet’s first half. As long as you keep this in mind, you can create any type of snippet you want!

For example, if you’re looking to engage more supporters by specifying their ZIP code, you might use a snippet like this in your form’s ask: {zip_code | area}. 

The corresponding parameter you would attach to your form’s URL would be “?zip_code=12345”. In that parameter, “zip_code” matches the label in the first half of the snippet, and “12345” is the custom content you want your donors to see.

This parameter would be added in the URL after your form’s name (“snippettest” in this example). With this parameter in the URL, the form will look like this:

Without the URL parameter, the form will show the default specified in the second half of your snippet, in this case “your area."

Besides ZIP code, other useful snippets specify city and state. You could also customize things like the donation amount or number of donors still needed in the donor’s area to reach your fundraising goal.