JS events: Page load

The articles object should contain all the pages where you want to run this code.

var adapter = OptiMonk.Visitor.createAdapter();
var currentArticle = window.location.pathname;
adapter.attr('showable', 'false');

const articles = {
    "/blogs/first-blog-sample": { title:"This is a first sample title","sub_title": "This is a first sample subtitle","button_text": "Sample button text","redirect_url": "/products/first-sample-product" },
    "/blogs/second-blog-sample": { title:"This is a second sample title","sub_title": "This is a second sample subtitle","button_text": "Sample button text","redirect_url": "/products/second-sample-product" }
}

if (articles[currentArticle]) {
adapter.attr('title', articles[currentArticle].title);
adapter.attr('sub_title', articles[currentArticle].sub_title);
adapter.attr('button_text', articles[currentArticle].button_text);
adapter.attr('redirect_url', articles[currentArticle].redirect_url);
adapter.attr('showable', 'true');
}

JS events: Popup fill

var adapter = OptiMonk.Visitor.createAdapter();
adapter.removeAttr('sub_title');
adapter.removeAttr('button_text');
adapter.removeAttr('redirect_url');
adapter.removeAttr('title');
adapter.removeAttr('showable');

JS events: Popup reject

var adapter = OptiMonk.Visitor.createAdapter();
adapter.removeAttr('sub_title');
adapter.removeAttr('button_text');
adapter.removeAttr('redirect_url');
adapter.removeAttr('title');
adapter.removeAttr('showable');

Campaign setting:

In order to display the campaign, you need to add the custom attribute as mentioned below.

Untitled