To build a page-aware chatbot, pass page URL/metadata from the browser (or data layer) into the widget, use your platform’s URL targeting rules, and enable Webpage Awareness plus optional custom context in CustomGPT.ai when you embed the agent.
Scope:
Last updated – November 2025. Applies globally; ensure page-aware chatbots respect existing site permissions and cookie/analytics consent under laws like GDPR and CCPA/CPRA when tracking URLs and user behavior.
You can also derive simple “page type” flags from the URL or path:
These values can be passed into your chat widget snippet (or into your data layer/analytics tags) so both your bot and your reporting know which page started the conversation.
Then in JavaScript:
You can forward these values when you bootstrap the chat widget. This lets your bot logic branch on things like:
Use the current page URL as chatbot context
Many chat widgets can accept extra parameters when you embed them. The simplest signal to send is the current page URL. That alone lets you change behavior or at least see where conversations started.Reading the URL with JavaScript
In the browser you can read the active page with standard JavaScript:| const pageUrl = window.location.href; // full URL const pagePath = window.location.pathname; // path, e.g. /pricing |
| const isPricingPage = pagePath.includes(‘/pricing’); const isBlogPost = pagePath.startsWith(‘/blog/’); |
Passing the URL into your chatbot widget
Here’s a generic pattern you can adapt to most widgets:- Grab the URL or path (window.location.href or window.location.pathname).
- Build a small config object, e.g. { pageUrl, pagePath }.
- When you initialize the widget, pass that object into its config or init function (often a global like window.chatConfig or a JS tag’s init call).
- In your bot platform, read that field as a custom attribute/parameter and:
- Route to different flows, or
- Insert it into the system prompt (“User is on: /pricing”).
- Store the URL in your analytics event for that chat session.
Pass page IDs, categories, or custom attributes
Raw URLs can be messy (query strings, tracking parameters, language codes). Often it’s more stable to pass a normalized value like a page ID or category.Using data attributes and global variables
A simple pattern is to encode page info in HTML:| <body data–page-id=“product-123” data–page-category=“product”> |
| const body = document.body; const pageId = body.dataset.pageId; const pageCategory = body.dataset.pageCategory; |
- pageCategory === ‘pricing’
- pageId === ‘product-123’
Using Google Tag Manager or a data layer
For more complex sites, it’s cleaner to use a data layer and Google Tag Manager (GTM):- Declare a dataLayer object on each page and push page info into it (ID, category, content type).
- In GTM, create Data Layer Variables for pageCategory, pageId, etc.
- Use those variables in tags that initialize your chat widget (or in custom HTML tags that call its API).
- Optionally, also send them to analytics tools (e.g. GA4) as event parameters.
Configure page-based behavior in chatbot platforms
Most modern chat platforms let you change where and how the bot appears based on URL rules.Page targeting and display rules
In tools like HubSpot, you can define targeting rules so a chatflow only shows specific URLs or URL patterns. Typical options include:- “Website URL is /pricing”
- “Website URL contains /blog/”
- “Website URL matches a regex pattern”
- Show bot A on all pages.
- Show bot B only on /pricing or /demo.
- Prioritize certain chatflows when multiple rules match the same page.
Page-specific greetings and playbooks
Once you have URL-based targeting, you can tailor:- Opening greetings (“Need help choosing a plan?” on /pricing).
- Playbooks or flows (e.g., a “book a demo” flow only on product or comparison pages).
- Embedded knowledge (“FAQ: refunds” on post-purchase pages).
How to do it with CustomGPT.ai
With CustomGPT.ai you get two key tools for page awareness:- Webpage Awareness – automatically summarizes the page the agent is embedded on and feeds that into the agent.
- Custom Context – lets you pass extra text parameters with each embed or call, like page type or user segment.
Enable Webpage Awareness for your agent
To make a CustomGPT.ai agent aware of the page it’s on:- In the CustomGPT.ai dashboard, open your agent.
- Click the three-dot (⋮) menu and choose Actions.
- Find Webpage Awareness in the list of agentic actions.
- Toggle it On.
- Deploy the agent on your site using the standard embed or live chat snippet.
- When users chat, CustomGPT.ai:
- Fetches and summarizes roughly the first chunk of page content,
- Stores that page summary, and
- Inject it into the agent’s system prompt so it can reference that page directly.
Pass extra page context with Custom Context
Sometimes page content alone isn’t enough. For example, you may want the agent to know:- “This is a product page for SKU-123 in the ‘Enterprise’ plan.”
- “This page is part of the onboarding flow.”
- Open your agent and go to the deployment settings (embed/live chat).
- In the embed configuration, add a custom_context field with a short description, like:
| “custom_context”: “Page type: pricing. Audience: prospects evaluating Enterprise plan.” |
- If you deploy on multiple templates, have each template output a tailored custom_context string.
- For API-based or advanced integrations, include the same field when you call the CustomGPT.ai API.
Track page-aware conversations in analytics
Once your bot is page-aware, you’ll probably want to see which pages drive the most engagement and what users ask on each one.Sending page info into chat events
There are two main streams of analytics:- Platform-native analytics
- With Webpage Awareness, CustomGPT.ai tracks which pages are summarized and how often page context is used across queries.
- External analytics (e.g., GA4)
- Use your data layer or widget events to send:
- page_path or pageCategory
- chat_open, chat_message_sent, chat_conversation_resolved
- Guides from chat vendors and analytics practitioners show how to push chat events into GA4 using GTM.
- Use your data layer or widget events to send:
Reporting on pages that drive conversations
Once events contain page data, you can:- Build reports showing which URLs generate the most chats.
- Compare conversion rates with and without chat on certain pages.
- Cluster common questions by page type (e.g., “shipping questions on /checkout”).
Example — Product page support chatbot
Imagine you run a SaaS product with /features, /pricing, and individual /product/* pages. You embed a CustomGPT.ai agent as a floating live chat. For this deployment:- Webpage Awareness is turned on, so the agent automatically reads and summarizes whichever product page it’s on.
- Each template also passes a custom_context string like: “This page describes Product X. Priority: highlight key benefits, integrations, and pricing FAQs.”
- The greeting becomes: “Have questions about Product X or choosing a plan?”
- If the user asks “Does this integrate with Slack?”, the agent answers using that product’s docs, not a generic answer.
- In analytics, you can see that /product-x generates more “ready-to-buy” conversations than /product-y, and tweak your content accordingly.