AI network map connecting Ballarat and Victoria regions

How to Create an Email Gated Download via a Breakdance Form

Table Of Contents

Need to add an email gated lead magnet? Use this when you want a Breakdance form submission to trigger a file download immediately (with a backup delivery method), without adding extra plugins.

How it works

  • User submits a Breakdance (lead magnet) form
  • Breakdance processes the submission normally (email/CRM/etc.)
  • A download starts automatically
  • User sees success message
  • Optional pop up with a backup download link

Create your email gated form and lead magnet downloader

1) Upload the lead magnet file

  • Upload the PDF to Media Library (recommended)
  • Copy the file URL (this becomes your link.href)

2) Build your Breakdance form

Email submission form with submit button.
  • Add your fields
  • Enable any actions you want
    • Email (backup delivery)
    • Popup on Success (backup manual download link and a confirmation message)
Select the options you want to use, you dont actually need to select any of them for this JS instant download to work, but the extra cool things you will need them as explained further below.

Built-in JS: Leave this empty

3) Set stable IDs on the form

In the form’s advanced settings:

  • Form HTML ID: e.g. MyDownload
  • (Optional) Submit button HTML ID if you’re doing extra UI control later

Lead magnet form setup interface options
IDs should be unique and descriptive so you can run multiple lead magnets on one page cleanly.

4) Add the download script (Code Block)

  • Drop a Code Block near the form (above or below is fine)
  • Paste the script and customise as needed
<script>
document.addEventListener("DOMContentLoaded", function () {
  
  // Match this to your Form HTML ID
  const form = document.getElementById("MyDownload");
  
  if (!form) {
    console.error("Form not found - check Form HTML ID");
    return;
  }
  
  form.addEventListener("submit", function (event) {
    event.preventDefault();
    
    // Let Breakdance process the form submission first
    setTimeout(() => {
      
      // Hide the form
      form.style.display = "none";
      
      // Show success message
      let successMsg = document.createElement("div");
      successMsg.id = "formSuccess";
      successMsg.innerHTML = "✅ <strong>Thanks!</strong> Your download is starting...";
      successMsg.style.cssText = "padding: 20px; background: #4CAF50; color: white; border-radius: 8px; text-align: center; font-size: 18px; margin-top: 20px;";
      form.parentNode.appendChild(successMsg);
      
      // Trigger the download
      const link = document.createElement("a");
      link.href = "/wp-content/uploads/2025/08/original-file-name.pdf"; // ← Your file path
      link.download = "BusinessName-File.pdf"; // ← User's download filename
      document.body.appendChild(link);
      link.click();
      document.body.removeChild(link);
      
    }, 800); // 800ms delay lets Breakdance process the form first
  });
});
</script>

Customisation needed

LineWhat It DoesHow to Customize
getElementById(“MyDownload”)Targets your formChange “MyDownload” to match your Form HTML ID
link.href = “…”Path to your fileUpload file to Media Library, copy URL, paste here
link.download = “…”Filename users seeChoose a clear, descriptive name like “Your-Business-Guide.pdf”
setTimeout(…, 800)Delay before downloadIncrease if form processes slowly (try 1200ms)

5) Provide a fallback path (don’t rely on auto-download alone)

Auto-download can be blocked on some devices/browsers, so always include at least one of:

  • Popup on Success with a manual download button/link
  • Email delivery (or both)

6) Test it out.

  • Test in incognito
  • Test on mobile Safari + Chrome
  • Confirm:
    • submission succeeds
    • success message appears
    • download triggers (or fallback link works)
    • the file URL opens directly in a browser

Need More Detail or Advanced Customisations?

This article covers basics, but If you need deeper guidance on:

  • Troubleshooting common Breakdance form or download issues
  • Multiple downloads on one page
  • Best practices for reliability, UX, and delivery
  • Optional Google Analytics / GA4 tracking for file downloads

? View the full implementation and advanced examples on GitHub:

What Others think about

    Comments are closed

    Subscribe to our blog

    Occasional emails from Vanessa at Brighter Websites about AI, SEO, Website Marketing for regional service businesses.  

    Want to Share Your Expertise?

    We’re always on the lookout for valuable insights to feature on the Brighter Websites blog. If you’re passionate about web design, SEO, marketing, or small business growth, we’d love to hear from you.
    Send your research or content ideas to Vanessa at support@brighterwebsites.com.au.

    Work with me

    Hit submit and I’ll reach out by email or phone to help you get started. Your details stay private,  see the Privacy Policy.

    Uh oh, the form hit a snag.

    Looks like something didn’t load right.

    Give it another go, or flick us a message at support@brighterwebsites.com.au  if it keeps failing. We’ll fix it faster than you can say “cache clear.”

    You can phone Vanessa too - she doesn't mind a chat 0412401933