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');
}
var adapter = OptiMonk.Visitor.createAdapter();
adapter.removeAttr('sub_title');
adapter.removeAttr('button_text');
adapter.removeAttr('redirect_url');
adapter.removeAttr('title');
adapter.removeAttr('showable');
var adapter = OptiMonk.Visitor.createAdapter();
adapter.removeAttr('sub_title');
adapter.removeAttr('button_text');
adapter.removeAttr('redirect_url');
adapter.removeAttr('title');
adapter.removeAttr('showable');
In order to display the campaign, you need to add the custom attribute as mentioned below.