Umbraco Engage
CMSCloudHeartcoreDXP
13.latest (LTS)
13.latest (LTS)
  • Umbraco Engage Documentation
  • Release Notes
  • Support
  • Installation
    • System Requirements
    • Installation
    • Licensing
    • Verify your Engage installation
  • Upgrading
    • Upgrade Umbraco Engage
    • Version specific Upgrade Notes
    • Migrate from uMarketingSuite
  • Getting Started
    • Getting Started
    • For Marketers and Editors
      • Cockpit
      • Marketing Resources
    • For Developers
      • Infrastructure sizing
      • Load Balancing and CM/CD Environments
      • Content Delivery Network recommendations
      • Cockpit
      • Content Security Policy nonce configuration
      • Troubleshooting installations
  • Marketers and Editors
    • Introduction
      • The Umbraco Engage Section
      • Content Apps
      • The Umbraco Engage Cookie
    • Analytics
      • What is measured by default
      • Client-side Events
      • Types Of Clients
      • Campaigns
      • Device Type
      • Location
      • Referral Traffic
      • Forms
      • Videos
      • Scroll Heatmap
      • Google Analytics vs Umbraco Engage
      • Search Terms
    • A/B Testing
      • What is A/B testing
      • Types of A/B Tests
        • Single-page A/B Test
        • Multiple Pages Test
        • Document Type Test
        • Split URL Test
      • Setting up the A/B Test
      • Previewing an A/B Test
      • Monitor the A/B Test
      • A/B Test Distribution Algorithm
      • Front end Rendering
      • Finish an A/B Test
    • Personalization
      • Creating a Segment
      • Setting up Personalization
      • Cockpit Insights
      • Implicit and Explicit Personalization
        • Setting up the customer journey
        • Personas
        • Implicit Personalization scoring explained
        • Content Scoring
        • Campaign Scoring
        • Referral Scoring
    • Profiling
      • Profile detail
      • External profile data
    • Reporting
    • Settings
      • Goals
      • IP Filtering
      • Configuration
      • Permissions
  • Developers
    • Introduction
      • Dataflow Pipeline
        • Data Collection
        • Data Storage
        • Data Parsing
        • Reporting
      • The Umbraco Engage Cookie
        • Module Permissions
      • Performance
    • Analytics
      • Request tracking
      • Bot detection
      • Capture location data
      • Extending forms
      • Video tracking
      • Scroll Heatmap
      • Client-side events
        • Additional measurements with analytics scripts
        • Bridging Library for Google Analytics
        • Bridging Library for Google Tag Manager
        • Google Analytics Blocker Detection
        • Create your own events
      • Extending Analytics
        • Getting the Correct IP Address
        • Sending data to the GTM Datalayer
    • A/B testing
      • Retrieving A/B test variants in C#
    • Personalization
      • Implement your own segment parameters
      • Retrieve segment information from code
      • Add custom scoring
    • Profiling
      • External Profile Data
    • Reporting
    • Settings
      • Custom goals scoring
      • Configuration
    • Headless
      • Using the Engage API
      • Headless Example
  • Security and Privacy
    • Security and privacy
    • Retention periods of data
    • Anonymization
    • GDPR & EU regulation
      • How to become GDPR compliant using cookiebot
    • How it works
  • Tutorials
    • Overview
    • How to Get Started with Personalization
    • How to Create a Persona
    • Create a Personalized Popup in 5 minutes
    • How to set up an A/B Test
    • Marketing Resources
      • Generic Topbar Template
      • Generic Popup Template
      • Generic Exit Intent Popup Template
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
Export as PDF
  1. Tutorials
  2. Marketing Resources

Generic Exit Intent Popup Template

To boost the marketing activitites on your website, you can add an exit intent popup to you website. Find a template for the popup in this article.

PreviousGeneric Popup Template

Last updated 4 months ago

Was this helpful?

Use this template to start boosting your marketing activities. The template can be set up and used without help from a developer.

It is recommended to personalize the popup to make it even more relevant for your specific audience.

Install the on your website to benefit from the full functionality of the template.

JavaScript & CSS

Copy and paste the CSS and JavaScript into Umbraco Engage and your overlay is ready.

CSS
:root {
  --c-lightbox-primary-surface: #3444b2;
  --c-lightbox-primary-contrast: #fff;
  --c-lightbox-secondary-surface: #3444b2;
  --c-lightbox-secondary-contrast: #fff;
  --c-lightbox-modal-background: rgba(0, 0, 0, 0.8);
}
.u-lightbox__container {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  justify-content: center;
  align-items: center;
  z-index: 999;
  display: none;
}
.u-lightbox__container.visible {
  display: flex;
}
.u-lightbox__scroll-container {
  position: relative;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 10;
  width: 100%;
  height: 100%;
}
.u-lightbox__background {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--c-lightbox-modal-background);
  opacity: 0;
  animation: fadeAnim 0.1s ease-in-out forwards;
}
.u-lightbox-alert-message {
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 25px;
  max-width: min(100%, 480px);
  box-sizing: border-box;
  font-family: system-ui, sans-serif;
  opacity: 0;
  animation: showAnim 0.8s cubic-bezier(0.68, 0.19, 0.14, 1.15) forwards;
  transition: all 1s;
  font-size: 16px;
  margin: 70px auto 60px;
  box-shadow: 2px 2px 30px rgb(0 0 0 / 20%);
}

.u-lightbox-alert-content strong {
  font-size: 1.2em;
  max-width: 90%;
  display: inline-block;
}

.u-lightbox-alert-content p {
  margin: 10px 0 0 0;
}

.u-lightbox-alert-button-container {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-bottom: -5px;
}

.u-lightbox-alert-button-container > * {
  margin-bottom: 5px;
}

.u-lightbox-alert-button-container > *:not(:last-child) {
  margin-right: 5px;
}

.u-lightbox-alert-button {
  appearance: none;
  border: 0;
  background: var(--c-lightbox-primary-surface);
  color: var(--c-lightbox-primary-contrast);
  padding: 8px 16px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 1em;
  font-weight: 600;
  text-decoration: none;
  transition: filter 0.2s ease;
  cursor: pointer;
}

.u-lightbox-alert-button:hover,
.u-lightbox-alert-button:focus {
  filter: brightness(1.1);
}

.u-lightbox-alert-button.secondary {
  background: var(--c-lightbox-secondary-surface);
  color: var(--c-lightbox-secondary-contrast);
}

.u-lightbox-alert-close {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 5px 10px;
  font-size: 0.8em;
  background: #eaeaea;
  color: #676767;
}

@media (max-width: 48em) {
  .u-lightbox-alert-message.absolute {
    max-width: 100%;
    width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    --sides: 0;
  }
  .u-lightbox-alert-button:not(.u-lightbox-alert-close) {
    width: 100%;
    text-align: center;
  }
}

@keyframes showAnim {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeAnim {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
JavaScript
(function () {
  // Change your settings below
  const exitIntentSettings = {
    useCookie: true,
    cookieName: 'EngageExitIntentShown',
    cookieExpireDays: 30,
    timeout: 0,
  };

  document.body.insertAdjacentHTML(
    'beforeend',
    `<div class="u-lightbox__container eng-exit-intent-popup">
      <div class="u-lightbox__scroll-container">
        <div class="u-lightbox-alert-message">
          <article class="u-lightbox-alert-content">
            <strong>Popups do convert!</strong>
            <p>
              Did you know that the average conversion rate of a popup 
              is 3.09%? So if you have 1000 visitors on a daily basis, 
              each month <b>927 visitors</b> will convert through this 
              popup.
            </p>
            <div class="u-lightbox-alert-button-container">
              <a href="https://www.umbraco.com/" 
                 class="u-lightbox-alert-button secondary">I want this!</a>
            </div>
          </article>

          <button class="u-lightbox-alert-close u-lightbox-alert-button">
            Close
          </button>
        </div>
      </div>
      <div class="u-lightbox__background"></div>
    </div>`,
  );
  const CookieService = {
    setCookie(name, value, days) {
      let expires = '';

      if (days) {
        const date = new Date();
        date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
        expires = '; expires=' + date.toUTCString();
      }

      document.cookie = name + '=' + (value || '') + expires + ';';
    },

    getCookie(name) {
      const cookies = document.cookie.split(';');

      for (const cookie of cookies) {
        if (cookie.indexOf(name + '=') > -1) {
          return cookie.split('=')[1];
        }
      }

      return null;
    },
  };
  const exit = (e) => {
    const shouldExit =
      // user clicks on mask
      [...e.target.classList].includes('u-lightbox__scroll-container') ||
      // user clicks on the close icon 
      [...e.target.classList].includes('u-lightbox-alert-close') || 
      e.keyCode === 27; // user hits escape

    if (shouldExit) {
      document.querySelector('.eng-exit-intent-popup').classList.remove('visible');
      if (umEngage) {
        umEngage('send', 'event', 'Popup', 'Close', 'Popup1');
      }
    }
  };

  const mouseEvent = (e) => {
    const shouldShowExitIntent = !e.toElement && !e.relatedTarget && e.clientY < 10;

    if (shouldShowExitIntent) {
      document.removeEventListener('mouseout', mouseEvent);
      document.querySelector('.eng-exit-intent-popup').classList.add('visible');
      if (exitIntentSettings.useCookie) {
        CookieService.setCookie(
          exitIntentSettings.cookieName,
          true,
          exitIntentSettings.cookieExpireDays,
        );
      }
    }
  };

  if (!CookieService.getCookie(exitIntentSettings.cookieName)) {
    setTimeout(() => {
      document.addEventListener('mouseout', mouseEvent);
      document.addEventListener('keydown', exit);
      document.querySelector('.eng-exit-intent-popup').addEventListener('click', exit);
    }, exitIntentSettings.timeout);
  }
})();

Feel free to play around with other properties. You can always use the code in this article to reset the styling.

client-side script