How to trigger HubSpot Popup Form from a button

Reading time 2 min.

HubSpot Popup forms are great for generating leads on your website, but they can only be shown with handful of triggers provided in the settings. And once visitor closes the popup, it won't trigger again until some time has passed.

Unfortunately there is no option to make a popup open from a button or link, but with little JavaScript magic you can make this happen.

Create your Popup form

For this to work, you first need to make sure popup is triggered on the page you want to open it. If you only want the popup to show on click, set the trigger delay on the form settings as high as possible so the popup won't open automatically.

You can do this on Targetig section under Triggers by ticking the After ellapsed time option and setting up the lay to maximum. 

Setting up your trigger button

On the page you want the link to be created, you need to add some custom JavaScript to your page. Easiest way to do this, is going under your page Settings section and under Advanced options placing the following code Additional code snippets input field.


$(function() {

setTimeout(function() {
      /* Change '#my-button' to query selector to your button class or ID */

      $("#button-id").click(function(event) {

    }, 400); 



Then add a a text link or button in your page content where you want to trigger the popup. To do this you need to go into source code editing mode, this can be found form the toolbar under Advanced menu selecting Source code. Find your link and add an id or class reference that matches the query selector in your JavaScript code.

<a href="#" class="cta_button" id="my-button">Open popup</a>

To se this in action, click the button below that opens my free marketing tips popup form:

Open popup

Note that if you have multiple popup forms active on the page, this method will only trigger the first one in the list.

Want to know more?

Ville Teikko

Ville Teikko

Ville Teikko is an award-winning creative & digital marketing specialist with over 20 years of experience in the digital design and advertising industry. Currently working as a Head of Digital at WaveCrest Finland.