Using the Snippet Feature for Conditional Content

In this article:

  1. Adding a donor name snippet
  2. Adding other custom snippets

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.

Adding a Donor Name Snippet

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 | friend} or {last_name | friend}, 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, “friend.”  

Adding Other Custom Snippets

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 (“edupdateform” 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.

Additional Reading

Search category icon

Creating & Customizing Contribution Forms

<br /> ActBlue user roles and permissions dictate what users can do on our platform. If the tools or features in this article are unavailable to you, speak to…