How to Enable Automatic URL Tracking with Webchat
With Fliqr AI, your webchat agent can now automatically detect the current URL of the page it’s embedded on. This functionality enables your bot to deliver more contextual responses, gather page-specific analytics, and streamline user interactions. Below are two primary ways to leverage this feature, along with notes on how to reference the captured URL inside your bot’s scripts.1. Default Usage (Simple Script Embed)
By default, you can embed the Fliqr AI script as shown below. No further configuration is needed for basic functionality:- The script (plugin.js?v=6) automatically captures the URL if loaded on the same page.
- You can reference the current URL in your chatbot logic using the custom field
{{webchat_parent_url}}.
2. Advanced Usage (Dynamic Script Loading)
If you need greater control over how the chatbot script operates—such as dynamically loading the script, managing specific states, or automatically opening the chat—you can use a custom initialization function. This approach provides flexibility and allows you to tailor the chatbot’s behavior to your specific needs. Custom Webchat Initialization:3. Optional <iframe> Embedding
If you embed the chatbot within an <iframe>, you must manually pass the parent parameter to the webchat URL:
encoded_url = encodeURIComponent(window.location.href).
Usage Notes:
- Embedding via
<iframe>is typically less flexible than loading the script directly on the page. - Remember to keep the parent parameter updated for accurate URL tracking if the user navigates within an SPA (Single-Page Application).
Referencing the Current URL ({{webchat_parent_url}})
Inside your chatbot’s flows, logic, or custom scripts, use the {{webchat_parent_url}} field to retrieve the current page URL.
Quick Reference Table
| Scenario | Embed Method | Script URL | URL Access |
|---|---|---|---|
| Default Setup | |||
| Advanced / Dynamic | |||
| iFrame Embedding | Pass parent in the query string |
Important Notes & Best Practices
- Use the Latest Version (v=6): If you’re still using v=5, update your script source to v=6 for automatic URL tracking.
- Single-Page Applications (SPA): If your site uses an SPA framework, ensure you update or reinitialize the chatbot on route changes, so the parent parameter remains accurate.
- Monitoring & Analytics: Use the URL data for detailed analytics. For instance, see which pages trigger the most chatbot interactions or track user engagement flows across your site.
