Automatically pop-up the Live Chat bubble just on selected pages
If you want to automatically pop-up Live Chat bubble just on a selected set of pages - you're in the right place.
CustomGPT.ai’s Automatically pop up the chat bubble option already lets the widget open itself on page load for desktop, mobile, or both.
But what if you want that attention‑grabbing popup only on high‑intent pages (e.g., pricing, checkout, documentation) and not on every visit to your blog
The page‑aware deployment script below gives you that fine‑grained control in just a few lines of code.
When & Why to Use Page‑Aware Auto‑Popup
Situation | Benefit |
---|---|
Conversion pages (pricing, sign‑up, demo request) | Draws visitors into a conversation the moment they show buying intent. |
Support articles / docs | Offers instant answers precisely where users get stuck, without nagging them elsewhere. |
Landing pages from ad campaigns | Tailors the welcome message and timing to the campaign for higher ROI. |
SEO Blog posts | Keep the chat available but silent, so content consumption isn’t interrupted. |
By limiting the popup to “hot” pages you maximize engagement while minimizing annoyance.
How the Script Works
- List “valid” paths – any URL path you place in validEmbedPaths is eligible for auto‑popup.
- Pick popup mode using the same constants CustomGPT uses in the dashboard:
const AUTO_POPUP_OPTIONS = {
NONE: 0, // No auto popup
DESKTOP_ONLY: 1, // Desktop only
MOBILE_ONLY: 2, // Mobile only
BOTH: 3 // Desktop & mobile
};
- Choose behaviour
autoPopupForValidPaths
→ what happens on pages in your listautoPopupForOtherPaths
→ what happens everywhere else (often NONE)
Step‑by‑Step Guide
- Identify the pages that should pop up (e.g.,
/pricing/
,/checkout/thank‑you.html
). - Copy the snippet and paste it instead of regular Live Chat code snippet:
<script src="https://cdn.customgpt.ai/js/chat.js" defer></script>
<script defer>
window.onload = () => {
// 1. List of paths that SHOULD auto‑popup
const validEmbedPaths = [
"/pricing/",
"/checkout/",
"/docs/getting-started/",
"/my/path/index.html"
];
// 2. Popup modes (same as dashboard)
const AUTO_POPUP_OPTIONS = { NONE:0, DESKTOP_ONLY:1, MOBILE_ONLY:2, BOTH:3 };
// 3. Configure behaviour
const autoPopupForValidPaths = AUTO_POPUP_OPTIONS.BOTH; // change if needed
const autoPopupForOtherPaths = AUTO_POPUP_OPTIONS.NONE; // stay silent elsewhere
// 4. Decide what to do for THIS page
const isValidPath = validEmbedPaths.includes(window.location.pathname);
const autoPopupChoice = isValidPath ? autoPopupForValidPaths : autoPopupForOtherPaths;
// 5. Initialise the Live Chat
CustomGPT.init({
p_id : "AGENT_ID", // ← replace
p_key: "AGENT_KEY", // ← replace
autoPopUp : autoPopupChoice,
args_priority: true // keeps URL param overrides if you use them
});
};
</script>
- Replace placeholders
AGENT_ID
→ your agent IDAGENT_KEY
→ your agent key
Tips & Variations
- Wildcards / starts‑with – For sections rather than exact paths, swap the equality check:
const isValidPath = window.location.pathname.startsWith("/docs/")
; - Single‑page apps (SPA) – Re‑run CustomGPT.init() whenever your router changes the path.
- Performance – All logic runs after window.onload; total overhead is a few milliseconds.
Updated 3 months ago