In some cases, website developers may require more control over which campaign is associated with a user. The Salespeak widget offers flexible JavaScript-based options to fine-tune the widget’s behavior and campaign targeting.
1. Dynamic Campaign ID Setting via Cookie
🧩 Overview
The Salespeak widget supports dynamic campaign ID setting via browser cookies. This allows developers to control which campaign is displayed, without editing the widget configuration.
⚙️ Configuration
Default Behavior
-
The widget checks for a cookie named
salespeak_dynamic_campaign_id
. -
The cookie value is treated as the campaign ID to use.
Custom Cookie Name
You can override the default cookie name by setting the data-dynamic-campaign-cookie-name
attribute in the script tag:
💡 Implementation Notes
-
Cookies must not be marked as HTTP-only (they need to be accessible via JavaScript).
-
When the cookie is detected, it overrides any other campaign configuration.
-
The widget ignores deployment settings if a valid campaign cookie is found.
🧪 Example
2. External JavaScript Integration
🧩 Overview
The Salespeak widget exposes an interactive module under window.salespeakLaunchersScript
, allowing advanced programmatic control.
🔍 Accessing the Module
window.salespeakLaunchersScript
is a Promise. Once resolved, it provides access to methods like:
-
config
: Modify widget settings -
init
: Initialize the widget -
remove
: Detach the widget -
reset
: Re-initialize with updated configuration
🔧 Available Methods
1. Remove the Widget
2. Change the Launcher Type
✅ Best Practices
-
Always
await
the Promise before using the module -
Call
reset()
after config changes to apply them -
Use
.catch()
to handle errors in production environments
🛡️ Safe Implementation Example
If you have any questions or encounter issues while implementing these controls, feel free to contact our support team.