How to control the lighbox(pop-up) should show once in a session? | Community
Skip to main content
Level 2
August 23, 2025
Question

How to control the lighbox(pop-up) should show once in a session?

  • August 23, 2025
  • 5 replies
  • 2401 views

I want to show 2 different offers(experiences) to 2 different audiences.  I have created the activity as Experience Targeting. My website is a SPA, but I have used different pages(the URL is not refresh when I move to next page). 

 

The lightbox open when the user go to the PDP pages. The pop-up open again and again in single session. 

Example: product1, product2, product3,.... User come to product1 page the popup showing but the user close the popup again go to product3 the popup showing again. 

 

But I want to control this, Once the user close the popup, it should not open in the same session. How can we achieve this?

5 replies

purnimajena
Level 3
August 25, 2025

Hi @jayasekar ,
You can handle this by setting a flag once the popup is closed and then checking that flag before showing it again. For example, use a sessionStorage variable (or a cookie) when the user closes the popup:

// When popup is closed
sessionStorage.setItem("popupClosed", "true");

// Before showing popup
if (!sessionStorage.getItem("popupClosed")) {
// show popup
}

OR
you can Create a profile script like popupClosed = true when user closes.Use an audience condition in your activity to only show the popup if popupClosed != true.

the first option with sessionStorage is usually enough — it ensures the popup won’t reappear again in the same session even if the user navigates to multiple product detail pages.

 

Kamal_Kishor
Community Advisor
Community Advisor
August 25, 2025

@jayasekar : Do you think using sessionStorage for storing the flag if pop-up is already shown can work for you? You can store this value on rendering of pop-up or click of close/accept/ok button on pop-up. Before rendering this pop-up, you can check if this flag/value is present in sessionStorage.

Since sessionStorage keeps values until you close your browser, it should not show it until you are in current session.

I don't understand your complete use-case but please see if this could work for you.

 

thanks.

Vishal_Anand
Level 5
February 11, 2026

@jayasekar  Use a short client-side flag to remember that the user closed the offer, then check that flag before asking Adobe Target to render the lightbox again. For SPAs you must run this check on route change rather than relying on full page loads.

Three simple options:

  • Quick (per-tab/session): sessionStorage — cleared when tab closes.
  • Across-tabs (single browser session): session cookie — cleared when browser session ends.
  • Robust (logged-in users): update a Target profile attribute (via trackEvent) so Target excludes the user server-side.

Example (vanilla JS + at.js pattern)

  • Show offer only if not closed:

JavaScript

const activityId = 'ACTIVITY_123'; // unique id per Target activity/experience

function shouldShowOffer() {
return !sessionStorage.getItem('target_closed_' + activityId);
}

function fetchAndRenderOffer() {
if (!shouldShowOffer()) return;

// request offer from Adobe Target (simplified)
adobe.target.getOffer({
mbox: 'product-promo',
success: function(offer) {
adobe.target.applyOffer({ offer: offer });
}
});
}

// call on initial load and on SPA route change
fetchAndRenderOffer();

// when user closes the lightbox
document.addEventListener('click', (e) => {
if (e.target.matches('.promo-close')) {
sessionStorage.setItem('target_closed_' + activityId, '1');
// optionally set cookie instead:
// document.cookie = `target_closed_${activityId}=1; path=/`;
// close DOM for the popup
}
});
  • React SPA example (hook on route change)

JavaScript

import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

function useTargetPromo(activityId) {
const location = useLocation();

useEffect(() => {
if (sessionStorage.getItem('target_closed_' + activityId)) return;

window.adobe?.target?.getOffer({
mbox: 'product-promo',
success: (offer) => window.adobe.target.applyOffer({ offer })
});

}, [location.pathname, activityId]); // run on route change
}


Option: update Target profile so Target excludes the user

  • When user closes the popup, call:

JavaScript

adobe.target.trackEvent({ mbox: 'profile-update', params: { promo_closed: true } });
  • Build a Target audience that excludes users with promo_closed=true. This prevents rendering server-side and is best for cross-device logged-in users.

Notes / caveats

  • sessionStorage = per-tab only. Use session cookies if you want cross-tab behavior.
  • If you have multiple experiences/audiences, use unique keys per activity/experience (e.g., target_closed_activity123_experienceA).
  • Profile updates require audience configuration in Target and may take effect on next decision call.
  • Make sure you still call Target for telemetry if you need impressions even when suppressed.
Perrin_Ennen
Community Advisor
Community Advisor
February 12, 2026

Hi ​@jayasekar

another option is to map this entirely via profileScripts and write and read the corresponding data in userProfile. This has the significant advantage that nothing needs to be written to the session storage, and you can design it however you wish. For example, we once had a requirement that a session be counted if the user was on the page for less than 30 minutes. Here, you can save a timestamp and offset it accordingly with the next request. This allows you to display a pop-up, for example, a maximum of once per session, if desired.

Hope this helps.

Jacinda E
Community Manager
Community Manager
February 13, 2026

Hey ​@jayasekar - following up on this older question. Looks like you got a few answers here - did any of them help you solve this issue? If so, please consider selecting a best answer to close out the thread and help others who might have the same question find this thread! 🙏