Offering some kind of free download is a great way to entice readers to signup for an email list. Perhaps you’re selling a premium course, and would like to offer readers a free e-book that supports the course. In exchange for the free e-book, you’d like your readers to sign up for your mailing list so that you can send them information about your course.
This is surprisingly simple to achieve, and you don’t need any special plugins to do it. If you already have a contact form plugin (ideally one that integrates with your mailing service), that should be all you need! We’ll take a look at how to create an opt-in download using Gravity Forms and MailChimp.
Creating the Opt-In Form
We’ll keep this very simple, but collect whatever info you need. In our form, we’ll collect a first and last name, and email address, like so:
MailChimp for Gravity Forms
For the MailChimp portion, make sure to install the MailChimp add-on for Gravity Forms. If you haven’t already, head over to Forms –> Settings –> MailChimp, and save your MailChimp API key.
Now, we can add a MailChimp feed for our opt-in form. In the form’s settings, click MailChimp –> Add New. Name your feed, select a list to which you want to add subscribers, and map your form fields to the MailChimp fields, and save. Your feed should look something like this:
Your form is now set up to add readers to your mailing list when they submit their info. Now on to the fun part!
Delivering the Opt-In Download
Now, let’s figure out how we want to deliver the opt-in download to our new list subscriber. We want to add a bit of security here in the sense that we at least want to verify the email address has actually been added to MailChimp. This is especially true for double opt-ins, since immediately redirecting readers to a download page after submission would result in handing over the download before they’ve completed their signup. To do this, we’ll add the reader’s submitted email address as a URL query parameter to our download page, and then link to that thank-you page from the MailChimp “Confirmation thank you page.”
To edit the “Confirmation thank you page,” head into your audience’s settings area, find the Signup Forms –> Form Builder area, and select the “Confirmation thank you page” option. Customize this page however you wish, but be sure to include a link to your download page with the proper URL query parameter. Something like this:
<a href="https://gravityforms.test/download?email=*|EMAIL|*" target="_blank">Click here to claim your e-book</a>.
Make sure to change the main part of that URL to the correct download page on your site. However, keep the ?email=*|EMAIL|* portion, as it is what we’ll use to verify the email has been fully added to our list.
Let’s now add in some validation to make sure the email in the URL is actually signed up for our list in MailChimp. Add the following snippet to your theme’s functions.php file, or a custom functions plugin.
This adds a shortcode that, when the email is subscribed in MailChimp, shows a “Download File” link for your readers to download the file. Make sure to change
$audience_id to the ID of your audience/list,
$dc to your data center (e.g. us3), and
$api_key to your API key (the same one you added in the Gravity Forms settings). The shortcode includes a
url attribute for setting the URL to the file.
With the code added, we can add the new shortcode to any page.
[optin_download url="download link here"]. Change the
url attribute to point to your file’s correct URL.
Note that this will not protect the file from being shared; this is only a way of showing you how to verify an email is subscribed before providing a link to the file. If you need to protect the file’s URL, you should customize this to fit your requirements, or opt for a more robust solution.
There you have it! A lightweight system for collecting emails and delivering a free download to subscribers, all with Gravity Forms!