Flag a Popup as Clicked With JS Code

Lisa Fockens Updated by Lisa Fockens

With our HTML blocks you can embed custom forms and buttons in your popups. When visitors interact with these popups, you want Wisepops to consider the popup as converted. So the conditions such as "Stop showing after the visitor has signed up" will work properly. You can let Wisepops know that a popup should be flagged as clicked with the help of our JS Callbacks.

Retrieve the popup object with Before popup display event

First, you need to retrieve the object that will let you manipulate the popup later. This is done by creating a callback that listens for Before popup display.

The popup object is available through event.detail.popup. The method that you will want to call is event.detail.popup.trackClick().

Call the trackClick() method at the right time

Now that you have access to the method, you need to call it when the click action occurs. There are various ways to do so. Lets assume that we want to track the click when the following button in a HTML block is clicked:

<button class="my-custom-button" type="button">Click here</button>

In the same JS callback created previously, we can rely on a native click listener to perform the action we want.

var button = event.target.querySelector('.my-custom-button');
button.addEventListener('click', function () {

We know that event.target is our popup container for the event Before popup display.

Please let us know if you have any questions or require further assistance.

Insert social widgets into your campaigns

Display a campaign when a product is added to the cart (Shopify)