Installing widget on selected pages
This tutorial guides you through setting up the Tiledesk live chat widget to display only on selected pages of your website. By leveraging a custom script, you can include or exclude the widget based on the page's URL. The script checks the current URL and decides whether to load the Tiledesk widget based on defined conditions, and it includes functions for login, logout, and custom authentication.
Step 1: Define Included/Excluded Pages
The script checks the current URL to decide if the widget should be loaded. Here’s how you can set up exclusions:
In this code, replace /cds, /dashboard, /login, etc., with the specific paths on your domain where you want to exclude or include the widget.
Step 2: Define the startWidget Function
The startWidget function loads the Tiledesk widget with the desired configuration, setting up the project ID and auto-start behavior.
Step 3: Additional Control Functions
The following functions provide additional control over the widget’s behavior:
tiledesk_widget_hide(): Hides the widget.
tiledesk_widget_show(): Shows the widget.
tiledesk_widget_login(attribute): Logs in the user with a custom attribute.
tiledesk_widget_logout(): Logs out the user and signs in anonymously.
These functions help manage the widget's state on different pages.
Step 4: Custom Authentication
The customAuth function sends user data to a custom authentication URL, receiving a JWT token that is used to sign in the user with Tiledesk.
Step 5: Testing and Verification
Verify Included/Excluded Pages: Visit the included pages to confirm the widget appears, and the excluded pages to ensure it remains hidden.
Test Login/Logout: Confirm that login and logout behaviors are working as expected, especially for the custom authentication flow.
This script provides granular control over where the Tiledesk widget appears, enhancing the user experience by excluding it from specific pages and enabling custom authentication.
Last updated