How to Create a Delayed Pop Up Web Template

MCP’s global exit intent pop up template fires when a user indicates they are about to leave a desktop website. To change this pop up to appear after a delay instead, use pageElementLoaded with a timeout.

function apply(context, template) {
    if (!context.contentZone) return;

    return SalesforceInteractions.DisplayUtils
        .bind(buildBindId(context))
        // Wait until an element in the dom has loaded
        .pageElementLoaded(".hero-section")
        .then(() => {
            if (SalesforceInteractions.cashDom("#evg-exit-intent-popup").length > 0) return;
            setTimeout(function () {
                const html = template(context);
                SalesforceInteractions.cashDom("body").append(html);
                // Other template code
            }, 3000);
        });
    }

Tracking

The pageExit utility does not detect exit intent on mobile devices since it depends on listening for mouse move events on a page. In order to track pop up interactions across desktop and mobile – explicitly add campaign stats tracking for impressions, clicks, and dismissals to your web template.

e.g. in the setDismissal click function:

// Track dismissal
const trackDismissal = {
      experienceId: context.experience,
      control: false,
      stat: "Dismissal"
};
SalesforceInteractions.mcis.sendStat({ campaignStats: [trackDismissal] });