Passing URL in captured Object
📍 Passing URL in captured
Object
🧾 Overview
The popInWidgetInit
function allows you to initialize a widget with user-specific and campaign-specific data.
One of the key fields you can include is the URL where the widget is triggered.
This is useful for tracking the source page or marketing campaign that led to user interaction.
⚙️ Function Usage
✅ Static URL Example
popInWidgetInit({
token: "12975",
captured: {
name: "Vijith",
mobile: "9544510895",
campaign: {
url: "https://www.example.com/cars",
},
},
});
🌐 Dynamic URL Example
To dynamically capture the current page URL, use window.location.href
:
popInWidgetInit({
token: "12975",
captured: {
name: "Vijith",
mobile: "9544510895",
campaign: {
url: window.location.href, // captures the current page URL dynamically
},
},
});
📄 Field Descriptions
token
string
✅ Yes
A unique identifier for your widget instance.
captured
object
✅ Yes
Contains data to be captured during the widget session.
name
string
Optional
The name of the user interacting with the widget.
mobile
string
Optional
The mobile number of the user.
campaign
object
Optional
Holds campaign-specific metadata.
campaign.url
string
Optional
Full URL of the page or campaign where the widget is triggered. Must include http://
or https://
.
📝 Notes
The
url
value must always be a valid and fully qualified URL (e.g.,https://www.example.com/page
).You can pass either:
A static URL (hardcoded)
A dynamic URL using
window.location.href
✅ Best Practices
Always include the full URL with
https://
orhttp://
to avoid malformed links.Use
window.location.href
to dynamically capture the current page.Avoid relative URLs (e.g.,
/sell-used-cars
) — always use absolute URLs.Perform URL validation or sanitization on your backend to prevent misuse or incorrect data capture.
Last updated