Stop Displaying a Campaign When the Cross Close Icon Is Clicked

Lisa Fockens Updated by Lisa Fockens

New! We now have a built-in targeting option to stop displaying a campaign when it has been closed. Simply check this option:

The method described in this article can still be useful if you want to prevent a campaign from being displayed if the visitor has closed another campaign. To do so, we will use our JS callbacks feature to declare a custom property.

Set the custom property when the close icon is clicked

First, let's add the property at the right time. Copy the following snippet into a JS callback listening for the event Before popup display:

var closeIcon ='.wisepops-close');

closeIcon.addEventListener('click', function() {
var properties = {};
properties['closed_' +] = new Date();
event.detail.wisepops('properties', properties);

This will create a custom property closed_1234, where 1234 is your campaign ID. So you can reuse the same method on multiple campaigns. Each one will have its own independent condition.

Prevent the display if the custom property has been set

Now, we want to exclude the visitors from the campaign if they have the custom property set. If we want the campaign to never appear again, we can add this condition:

closed_1234 does not exist

Remember that 1234 must be replaced by your actual campaign ID. You can find this ID in the URL of our campaign builder:

We can also choose to display the campaign again two hours after the close icon was clicked, with the following:

closed_1234 does not exist
closed_1234 is before 2 hours ago

Don't hesitate to contact our support if you have any questions or need further advice!

Frequency Settings