If your store has a side cart, drawer menu, or mobile navigation that slides over the page, you can keep your popups from opening while it's open. This stops the popup and the menu from overlapping.
You'll do this with a targeting rule that runs a short piece of code. In this guide you'll:
Find your menu or cart's selector in your browser's developer tools.
Create a targeting rule that checks whether it's open.
Add the rule to your campaign.
đĄ Note: To hide popups on certain pages instead, see Hide popups on certain pages.
Step 1: Find your menu or cart's selector
Open your store in a desktop browser.
Open the side cart or menu you want to check for.
Right-click it and select Inspect to open the developer tools.
Close and reopen the menu, and watch which attribute on the element changes.
You're looking for two things:
A unique ID on the menu or cart element.
A class that's only there while it's open.
For example, you might see:
<div id="site-mobile-nav" class="visible">
Here, the ID is #site-mobile-nav and the open-state class is visible. Every theme is different, so your names will vary.
Step 2: Create a targeting rule
In Alia, go to Campaigns > Targeting rules.
Click Create rule.
Click Select a filter and choose Custom code.
[Screenshot: Select a filter > Custom code, from the Notion draft]
Paste this code:]
return !document.querySelector('#site-mobile-nav')?.classList.contains('visible');Replace
#site-mobile-navwith your element's ID (keep the#), andvisiblewith your open-state class.Give the rule a clear name, such as "Side cart closed". Changes on the Targeting rules page save automatically.
How the rule works
While the menu is open, the code returns
false, so the visitor doesn't match and the popup doesn't open.While it's closed, the code returns
true, so the visitor matches.If Alia can't find the element at all, the code also returns
true, so popups still show.
Alia checks targeting about once a second while the visitor is on the page, so the popup can open as soon as the menu closes.
Step 3: Add the rule to your campaign
Go to Campaigns and click Targeting on the campaign's card.
Click Select a filter and choose In targeting rule or campaign.
Choose the rule you created.
Click Save.
The campaign's popup won't open while the side cart or menu is open.
đĄ Tip: If only one campaign needs this, you can skip the saved rule and add the Custom code condition straight to that campaign's targeting. A saved rule is easier when several campaigns need it, because you only update it once.
Tips
Test on both desktop and mobile. Some themes use different elements for the mobile and desktop menus, so you may need a rule for each.
Make separate rules for carts, menus, and search overlays, or combine them in one rule.
If the popup still appears, check that the ID and class match exactly. They're case sensitive.
Your code must return exactly
trueto match, within one second.
Still have questions?
Start a chat from inside the Alia app, or use the chat in our Help Center.





