How to Deliver Downloadable Files

There are several methods you can use to deliver downloadable files to your new subscribers when using OptinMonster. In this document we’ll cover the possible campaigns and some tips to help get you started with the solution that best fits your needs.

Before we jump into the available options, be sure you’ve uploaded the file you wish to provide to a remote server since OptinMonster does not host files for you to provide to subscribers.

Depending on your Setup with OptinMonster, you have a couple different options:

  1. Email the Downloadable File
  2. Native Integrations
  3. Custom HTML and Canvas

Email the Downloadable File

You can easily email your new subscriber the link to your downloadable file. You’ll set this option up through your Email Service Provider.

You can provide the file in your first email to new subscribers, or make it part of a campaign sequence if your Email Service Provider allows you to create sequences.

Pro: The benefits of this method is that it ensures that only legitimate email addresses receive your lead magnet.
Con: You don’t have the benefit of offering an “instant download” which is more attractive for web visitors. In addition, you have an additional step to set up within your Email Service Provider.

Native Integrations

If you are using on of our Native Integrations, then you have access to our Success Actions.

Therefore, you have 3 options:

Option 1 – Lightbox Success Theme

When using any of our native Email Service Provider integrations you can display a Success Message when the campaign is successfully submitted.

To do this, go you to Success Menu Item in the Builder. Then click Switch Theme.

switch-theme-to-download-theme

Choose the Download Theme.

download-theme-chosen

Next, in your Success Fields column, you should see the field Download Location Enter the full URL where your downloadable item is located. This field will automatically setup your Download Now button.

add-download-link

Finish setting up any additional settings you are good to go. Don’t forget to save your campaign before exiting.

Alternatively to the Download Success Theme, you could use another Success Theme such as the Default Success Theme.

You can write up your message, with something like:

“Thanks for subscribing. You can get the free download by clicking here.”

Next, highlight the works click here. You should see a formatting toolbar show up in the builder.

highlight-text-to-link

Click the “chain link” button for hyperlinking text. Now you will paste the URL into the field, and click Add.

hyperlink-your-desired-text-to-your-downloadable-item

text-linked-to-downloadable-file

Great work. Save your campaign and you’re ready to go.
Option 3 – Redirect to Page Containing the Download Link

If you’re using one of our native Email Service Provider integrations you can set a Redirect URL in the Configuration panel of the Campaign Builder to direct new subscribers to after successfully submitting the campaign. If you’re using our Custom HTML Optin Form integration option or Canvas Technology to add your form to a campaign you can setup the redirect URL through your Email Service Provider.

Once you’ve set the Redirect URL, add your download link to the page you’re directing new subscribers to.

Custom HTML and Canvas

For non-native integrations, you can use the Custom HTML option or Canvas. The difference between the two is that Custom HTML utilizes OptinMonster’s templates, while letting the form be your custom embed code, whereas Canvas is entirely a “blank” modal window.

This also means that Custom HTML can use Success Triggered Scripts, whereas Canvas cannot. Therefore, to deliver downloadable items, it depends on which option you choose to implement.

Custom HTML Integration Option

For Custom HTML integrations, you can use the Success Triggered Scripts to automate the download process. A prerequisite for this to work is that your campaign must register a conversion. More information on how to do that can be found on our How to Track Conversions with Custom HTML guide.

Note: You should always wrap your JavaScript in <script> tags.

Enter any scripts that should be fired when your campaign is successfully submitted into the Success Triggered Scripts field in the Campaign Builder.

To deliver your file, get the full URL location of that file ready. Copy that URL, and paste in near the end of the code example below in place of the “…example.com” URL in the SaveToDisk function.

Note: Since this code example is beyond the standard function of OptinMonster, the OptinMonster support teams does not provide support for the example code provided. You may need to hire a web developer for additional support in your customized implementation. Related: OptinMonster JavaScript Events API Documentation.
// Function SaveToDisk forces file download instead of viewing in browser
function SaveToDisk(fileURL, fileName) {
    // for non-IE
    if (!window.ActiveXObject) {
        var save = document.createElement('a');
        save.href = fileURL;
        save.target = '_blank';
        save.download = fileName || 'unknown';
 
        var event = document.createEvent('Event');
        event.initEvent('click', true, true);
        save.dispatchEvent(event);
        (window.URL || window.webkitURL).revokeObjectURL(save.href);
    }
 
    // for IE
    else if ( !! window.ActiveXObject &amp;amp;amp;&amp;amp;amp; document.execCommand)     {
        var _window = window.open(fileURL, '_blank');
        _window.document.close();
        _window.document.execCommand('SaveAs', true, fileName || fileURL)
        _window.close();
    }
}
 
// Update with the url of the file you want downloaded on campaign submission
SaveToDisk('http://www.example.com/download-file.pdf');
Click save and that’s it! Your campaign should start the download process when the user signs up for your email newsletter.
Canvas Technology

For Canvas Users, you need to add JavaScript inside of the Custom HTML tag area. A prerequisite for this to work is that your campaign must register a conversion. More information on how to do that can be found on our How to Track Conversions with Canvas Technology guide.

Since Canvas Templates don’t offer a Success menu area, you will need to add the code into the Custom HTML area. Because of this, you also need to wrap the code in script tags.

OptinMonster-SaaS-Canvas-Optin-Add-Custom-Code

To deliver your file, get the full URL location of that file ready. Copy that URL, and paste in near the end of the code example below in place of the “…example.com” URL in the SaveToDisk function.

Note: Since this code example is beyond the standard function of OptinMonster, the OptinMonster support teams does not provide support for the example code provided. You may need to hire a web developer for additional support in your customized implementation. Related: OptinMonster JavaScript Events API Documentation.
/ Function SaveToDisk forces file download instead of viewing in browser
function SaveToDisk(fileURL, fileName) {
    // for non-IE
    if (!window.ActiveXObject) {
        var save = document.createElement('a');
        save.href = fileURL;
        save.target = '_blank';
        save.download = fileName || 'unknown';
 
        var event = document.createEvent('Event');
        event.initEvent('click', true, true);
        save.dispatchEvent(event);
        (window.URL || window.webkitURL).revokeObjectURL(save.href);
    }
 
    // for IE
    else if ( !! window.ActiveXObject &amp;amp;amp;&amp;amp;amp; document.execCommand)     {
        var _window = window.open(fileURL, '_blank');
        _window.document.close();
        _window.document.execCommand('SaveAs', true, fileName || fileURL)
        _window.close();
    }
}
 
jQuery(document).ready(function($){
 
     // Specify the OptinMonster Event that will trigger our file download
     $(document).on('OptinMonsterOptinSuccess', function(event, data, object){
 
          if(data.optin == 'your-first-optin-slug') {
             // Update with the url of the file you want downloaded on campaign submission
             SaveToDisk('http://www.example.com/download-file-1.pdf');
          }
 
          if(data.optin == 'your-second-optin-slug') {
             // Update with the url of the file you want downloaded on campaign submission
             SaveToDisk('http://www.example.com/download-file-2.pdf');
          }
 
          if(data.optin == 'your-third-optin-slug') {
             // Update with the url of the file you want downloaded on campaign submission
             SaveToDisk('http://www.example.com/download-file-3.pdf');
          }
 
     });
 
});
&lt;/script&gt;
Click Save and you’re good to go!