Running an Experience during a scheduled time period

THIS ARTICLE WILL HELP YOU:

Introduction

Convert lets you schedule your experiments or campaigns to start and stop them at specific times. 

This is the more advanced option to stop your experiments at a certain time, but the harder to implement. However, if you would like an easier way you can use the maximum days setting on the Stats section, or you can also use the audience segmentation visit time field.

 

Add Moment.js Library

First, you will need to include the moment.js library into your project. You can do this by adding the following line into the Global Project Javascript:


convert.$.getScript("https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.3/moment.min.js", function(){

console.log("moment.js has been included.");

});

It will look like this:

mceclip0-Aug-20-2024-03-55-43-3122-AM

Add JS Condition on Audiences

Now include the following code as a Javascript Condition on your Audience, replacing the date and time shown in bold below with the specific date(s) and time(s) you are targetting:

(function() {
if (typeof moment == 'undefined') {
convert_recheck_experiment();
} else {
return moment().isBetween('2018-01-12 00:00:01', '2018-01-15 23:59:59');
}
})()

It will look similar to the screenshot below:

mceclip0.png

Moment will interpret the date as the user's local computer time, but if you want to specify a time zone or UTC offset or do anything more complex, please refer to the official documentation:

https://momentjs.com/guides/

http://momentjs.com/docs/