Skip to main content
All CollectionsTriggersAdvanced trigger control
Stop triggered emails being sent when the current date is past the start date
Stop triggered emails being sent when the current date is past the start date

Use this solution where a start date is captured against Browse/Cart Signals.

Updated over 6 months ago

This solution is primarily tailored for holiday businesses or similar situations. It helps prevent emails from being sent, for example, when customers define a start date for their holiday, then abandon the site, and the current date has already passed the holiday's start date.


Before you start

Things you need to know:

  • You must ensure that a Start Date is captured against your Signals. You can verify this information in the Audit Logs for Visitor Records. For example, the following account captures an 'arrival_date' field:


    If this is not being captured as required, contact Support.


Solution

  1. Go to Triggers in the left side menu.

  2. Select the Trigger Programs tab.

  3. Select the trigger program you want to edit.

  4. Under Advanced Features, select EDIT SCRIPT.

  5. Copy and paste the code below into the script field:

    function parseDate(dateString) {
    if (dateString.includes("-")) {
    var parts = dateString.split("-");
    } else if (dateString.includes("/")) {
    var parts = dateString.split("/");
    } else {
    return null;
    }
    if (parts[0].length === 4) {
    return Date.parse(parts[0] + "-" + parts[1] + "-" + parts[2]);
    } else {
    return Date.parse(parts[2] + "-" + parts[1] + "-" + parts[0]);
    }
    }
    result.proceed = false;
    var currentDate = new Date();
    var startDate = INSERT SIGNAL FIELD HERE;
    // If signal field does not exist, startDate will be undefined
    if (startDate) { // Check if startDate (signal field) exists
    var formattedDate = new Date(parseDate(startDate));
    if (formattedDate > currentDate) {
    result.proceed = true;
    } else {
    result.proceed = false;
    }
    } else { // If startDate (signal field) does not exist (
    undefined), set result.proceed to true
    result.proceed = true;
    }

    You must replace INSERT SIGNAL FIELD HERE on Line 19 with the start_date or holiday_date variable you’re capturing. For example:

    • cart.p[0].opt.arrival_date

    • cart.p[0].opt.arrival

    • cart.p[0].opt.start

    • cart.p[0].opt.start_date

    The script only supports the following date formats:

    • YYYY-MM-DD

    • DD-MM-YYYY

    • YYYY/MM/DD

    • DD/MM/YYYY

  6. Select RUN to test the script to confirm its functionality for your account:

  7. Select SAVE.

We advise that you then monitor the Audit Logs of your visitors over the next few days. To do this, you can check Browse/Cart Abandon Signals for visitors:

  1. Go to Reports > All Reports.

  2. Expand the Site Activity & Insight drop-down menu and select Browse and Cart Abandons.

Did this answer your question?