Hey there!Â
This is such a great question. Yes you absolutely can exclude pop ups from urls that contain certain parameters as you have done. Unfortunately as the users url changes throughout their journey, the ideal way to do this would be with being able to identify and exclude their cookie . Unfortunately Klaviyo doesn't have a built-in way for users directly modify pop-up scripts or use cookies natively, but you can work around this using targeting settings and some custom JavaScript.Â
Â
Step 1: Establish a Cookie at the Website Level for Affiliate Visitors
First, the affiliate=true cookie still needs to be set on your website. Include this script in the <head> section of your website or using your tag manager (like Google Tag Manager):
if (window.location.search.includes('ref=affiliate')) { document.cookie = "affiliate=true; path=/; max-age=86400"; // Cookie lasts 1 day }
By taking this step, you can make sure that everybody who visits your website via an affiliate link (such as ?ref=affiliate) receives a cookie that stays on your site throughout all pages.
Step 2: Use Klaviyo's Targeting Settings
While Klaviyo doesn’t let you directly modify pop-up scripts, you can use Targeting & Behaviour settings to control when a pop-up appears.
-
Go to Your Pop-Up Form in Klaviyo:
- Navigate to the form you want to hide for affiliate visitors.
-
Set Targeting Rules:
- To exclude particular URLs, add a Targeting Rule in the Targeting & Behaviour section.
Select "Don’t show on certain URLs" and include the following condition: URLs that contain the parameter ‘affiliate’
This guarantees that the affiliate landing page (i.e., the URL with ?ref=affiliate) will not display the form.
Step 3: Combine Targeting with Custom JavaScript (Advanced)
You will need to create a custom script to keep the pop-up hidden when visitors move to other pages (where the ?ref=affiliate argument vanishes). You can use JavaScript to stop the Klaviyo pop-up from loading depending on the affiliate cookie, even though Klaviyo doesn't enable cookie detection for pop-ups natively.
Here’s how:
-
Add a Custom JavaScript Check:
Insert the following script into your website’s global JavaScript file or your tag manager (e.g., Google Tag Manager)
Where to Add This Code
You can add this JavaScript in one of the following ways:
Directly in Your Website's Code: Add it to the <head> or at the bottom of the <body> tag in your main HTML template.
Via Google Tag Manager:
Create a new tag in GTM.
Select Custom HTML and paste the script into the editor.
Set the trigger to All Pages.
CODE:
// Function to hide Klaviyo pop-ups if "affiliate" cookie exists
function hideKlaviyoPopups() {
    if (document.cookie.includes('affiliate=true')) {
        // Find all Klaviyo forms and hide them
        document.querySelectorAll('Âid^="klaviyo-form"]').forEach(form => {
            form.style.display = 'none';
        });
        console.log("Affiliate visitor detected - Klaviyo pop-ups hidden");
    }
}
Â
// Run the function when the page loads
document.addEventListener("DOMContentLoaded", hideKlaviyoPopups);
Â
-
Explanation:
 This script checks for Klaviyo forms (
It works site-wide, so the pop-up won’t appear on any page for visitors with the affiliate=true cookie.
Step 4: Test the Implementation
Visit your site with an affiliate link (e.g., yourwebsite.com?ref=affiliate) and verify that:
The cookie (affiliate=true) is set.
The pop-up doesn’t appear on any page, even after navigating.
Test a non-affiliate link to confirm the pop-up works as expected for regular visitors.
 Simplified Alternative (No Cookies)
If cookies are too complex, you can rely solely on Klaviyo’s URL-based targeting:
Use UTM parameters (e.g., ?utm_source=affiliate).
Exclude all URLs with the parameter using Klaviyo's "Don’t show on certain URLs" rule.
For short affiliate trips, this might still be effective, but the drawback is that the pop-up might recur once the visitor navigates to a product page.
The Reasons Klaviyo + Cookies Work
Although cookie-based targeting is not built into Klaviyo, integrating Klaviyo's URL rules with cookie logic on your website could help a smooth experience for both affiliate visitors and loyal clients.