How do I trigger a pop-up CTA in a custom module?

I’m trying to add the ability to trigger a pop-up CTA from a custom-coded module but I can’t figure out how to get it to work. From what I can tell there are 2 ways to do this:

The first is to use the URL parameter and select the ‘type’ as Pop-up CTA.

but I don’t really know what I’m supposed to do with this - which parameter from the URL do I use and how do I trigger it? If I just use it like I normally would use a URL field:

<a href="{{ module.url.href }}">Click here</a>

It doesn’t seem to have an href value (just goes to an empty page) and I can’t find any documentation regarding this field so I’m not really sure what to do with this.

The other way would be to utilize the `hs-cta-trigger-button` classes for ‘external’ sites - but if I put these classes in the module, nothing happens when I click on the button. No console errors or anything that I can see to point me in the right direction, just nothing happens.

<button class="hs-cta-trigger-button hs-cta-trigger-button-1234567">Click here</button>

I feel like I must be missing something glaringly obvious, but I can’t figure out what it is. Any help would be appreciated!

I know you can accomplish this with the default ‘button’ module but I would like to avoid this as it doesn’t work for the way I’ve structured everything and I want to have more control over the styling.

Hi @DCardinal3,

if you create a link option and copy the whole snippet(works with every field; but most times “value” is enough) and paste it into the module.html, you will see the correct variable and - in this case - the whole link structure.

In my example(screenshot) the copied snippet looks like this:

{% set href = module.link_field.url.href %}
{% if module.link_field.url.type is equalto "EMAIL_ADDRESS" %}
 {% set href = "mailto:" + href %}
{% endif %}
<a
 {% if module.link_field.url.type is equalto "CALL_TO_ACTION" %}
 href="{{ href }}" {# The href here is not escaped as it is not editable and functions as a JavaScript call to the associated CTA #}
 {% else %}
 href="{{ href|escape_url }}"
 {% endif %}
 {% if module.link_field.open_in_new_tab %}
 target="_blank"
 {% endif %}
 {% if module.link_field.rel %}
 rel="{{ module.link_field.rel|escape_attr }}"
 {% endif %}
 >
 Link text
</a>

the important part is the info: “The href here is not escaped as it is not editable and functions as a JavaScript call to the associated CTA”.

This means that you’re on the right track with your first option. If you have only the Pop-Up-CTAs as option for this button, you can write the code like this:

{% set href = module.link_field.url.href %}

<a href="{{ href }}" >Click here</a>

best,

Anton

Amazing, thank you so much!