I am trying to create a popup form that opens when a user clicks on a CTA button. However, as the CTA button requires a URL to create, the popup form is not opening as intended.
I would appreciate any assistance on how to resolve this issue.
I suggest using the dialog element that will be toggled by a button. It's also recommended to write your javascript without jQuery for better support if jQuery get's disabled inside your HubSpot portal.
Here a code example that you also can check on CodePen.
HTML
<button class="button">
Open Modal
</button>
<dialog class="modal" aria-state="closed">
<div class="modal__wrapper">
<button class="modal__close">✕</button>
<div class="modal__content">
Add form. Lorem ipsum dolor sit amet consectetur adipisicing elit. Impedit voluptate deleniti maxime ea nisi ipsum tenetur ipsam repudiandae itaque nobis.
</div>
</div>
</dialog>
@dar_261991 HubSpot has a new Pop-up CTA feature that let's you open a form on button click.
From Marketing > Lead Capture > CTAs:
When you click Create, you can choose from Templates (like the Download Email Template) or Start from scratch to build your own
The module where you are adding the Button/CTA does have to have the "Pop-up CTA" URL type enabled in the field setting to add the pop-up you've created to the page.
If my reply answered your question please mark it as a solution to make it easier for others to find.
@dar_261991 HubSpot has a new Pop-up CTA feature that let's you open a form on button click.
From Marketing > Lead Capture > CTAs:
When you click Create, you can choose from Templates (like the Download Email Template) or Start from scratch to build your own
The module where you are adding the Button/CTA does have to have the "Pop-up CTA" URL type enabled in the field setting to add the pop-up you've created to the page.
If my reply answered your question please mark it as a solution to make it easier for others to find.
Hi Jennifer - I'm trying to use the new pop-up cta with form, but the form is opening in a new blank window. Do you know how to troubleshoot that? Here's the page. And it's the 2 toolkit buttons and 3 guide buttons that have the pop-up form. I'm also using smart content, so that if someone has a member of a list, they don't see the form.
Hi @SArnold13 when I view the page, the pop-up form opens as expected, but there's a link for "Download the TLF today" that goes directly to the PDF in a new tab rather than the pop-up form - is that the one you're referring to?
For me, the pop-ups open like this:
If my reply answered your question please mark it as a solution to make it easier for others to find.
I suggest using the dialog element that will be toggled by a button. It's also recommended to write your javascript without jQuery for better support if jQuery get's disabled inside your HubSpot portal.
Here a code example that you also can check on CodePen.
HTML
<button class="button">
Open Modal
</button>
<dialog class="modal" aria-state="closed">
<div class="modal__wrapper">
<button class="modal__close">✕</button>
<div class="modal__content">
Add form. Lorem ipsum dolor sit amet consectetur adipisicing elit. Impedit voluptate deleniti maxime ea nisi ipsum tenetur ipsam repudiandae itaque nobis.
</div>
</div>
</dialog>
Basically you can't do this with Hubspot CTAs (and retain the tracking that comes with CTAs). You have to create your own button and JS to display and hide a popup form.