You can set up the checkout widget to open automatically when a customer clicks a link in an ad, social post, or email. This lets you drop them directly into the booking flow — even with a product preselected or a promo code already applied.
How to Implement
Copy the code below to the page where the widget is implemented.
Update the example values to match your own.
Copy this code:
Copy this code:
📒 NOTE
Ignore or delete lines that start with //
. These provide guidance or context.
function openWidgetFromURL () {
// For production use, this line must be uncommented.
//const urlParams = new URLSearchParams(window.location.search);
// For production use, these two lines need to be deleted.
// It is just code used to help with testing on jsfiddle.
const temporaryURL = new URL('https://example.com/page?openWidget=true')
const urlParams = new URLSearchParams(temporaryURL.search)
const openWidget = new URL (url).searchParams.get('openWidget');
return openWidget;
}
window.addEventListener('load', function() {
if (openWidgetFromURL()) {
if (typeof window.Ventrata === 'function') {
// The Ventrata function takes same parameters ad data-config, so you can pass in the ProductID and other necessary values. So, for example, if you want to apply a promo code right on the first view, you just need to use this.
window.Ventrata({"productID": "a870745f-3455-44d6-bb790c6cf61e41e58", "promoCode": "QLSGZC"});
} else {
console.error('Ventrata checkout did not load.');
}
}
});
📒 NOTE
If you need help setting up your marketing URL with query parameters, reach out to your Customer Success Representative for assistance.
How It Works
Your marketing link includes openWidget
(and optionally other parameters, such as promoCode
).
https://example.com/page?openWidget=true'
The script from above reads those instructions from the URL. If openWidget
is present, it opens the widget and passes along extra values (like promo code). The widget opens with the right code already set — fewer clicks for the customer.
Customer Flow
You place a special link in your ad, social post, or email.
A customer clicks this link and lands on your site.
The checkout widget opens automatically with the settings you defined (product already selected, promo code applied).
Common Patterns
A single link can carry multiple query parameters, or instructions, to the checkout, such as:
Open widget + apply promo code
Open widget + apply promo code
Example marketing URL:
https://example.com/page?openWidget=true&promoCode=QLSGZC
Example code:
function openWidgetFromURL() {
// For production use, this line must be uncommented.
//const urlParams = new URLSearchParams(window.location.search);
// For production use, these two lines need to be deleted.
// It is just code used to help with testing on jsfiddle.
const temporaryURL = new URL('https://example.com/page?openWidget=true&promoCode=QLSGZC')
const urlParams = new URLSearchParams(temporaryURL.search)
const openWidget = urlParams.get('openWidget')
const promoCode = urlParams.get('promoCode');
return {openWidget, promoCode};}
window.addEventListener('load', function() {
const { openWidget, promoCode } = openWidgetFromURL();
if (openWidget) {
if (typeof window.Ventrata === 'function') {
// The Ventrata function takes same parameters as data-config, so you can pass in the productID
// and other necessary values. So, for example, if you want to apply a promo code right
// on the first view, you just need to use this.
window.Ventrata({"productID": "a870745f-3455-44d6-bb79-c6cf61e41e58", "promoCode": promoCode});
} else {
console.error('Ventrata checkout did not load.');
}
}
});
Open widget + open specific product + apply promo code
Open widget + open specific product + apply promo code
Example marketing URL:
https://example.com/page?openWidget=true&promoCode=QLSGZC&productID=d6a2b90a-6c2a-46e8-9eab-8efb732019e6
Example code:
function openWidgetFromURL() {
// For production use, this line must be uncommented. //const urlParams = new URLSearchParams(window.location.search);
// For production use, these two lines need to be deleted. // It is just code used to help with testing on jsfiddle.
const temporaryURL = new URL('https://example.com/page?openWidget=true&promoCode=QLSGZC&productID=d6a2b90a-6c2a-46e8-9eab-8efb732019e6')
const urlParams = new URLSearchParams(temporaryURL.search)
const openWidget = urlParams.get('openWidget')
const promoCode = urlParams.get('promoCode')
const productID = urlParams.get('productID');
return {openWidget, promoCode, productID};}
window.addEventListener('load', function() {
const { openWidget, promoCode, productID } = openWidgetFromURL();
if (openWidget) {
if (typeof window.Ventrata === 'function') {
// The Ventrata function takes same parameters as data-config, so you can pass in the productID
// and other necessary values. So, for example, if you want to apply a promo code right
// on the first view, you just need to use this.
window.Ventrata({"productID": productID, "promoCode": promoCode});
} else {
console.error('Ventrata checkout did not load.');
}
}
});
Best Practices
✅ Do | ❌ Don't |
URL-encode promo codes if they have spaces/symbols | Include any personal data in URLs |
Keep using UTMs alongside checkout parameters to measure performance | Leave a hard-code testing URL in production |
Add more parameters (for example, language=en) |
|
Benefits of Multiple Query Parameters
🖱️Fewer clicks = higher conversion
Drop customers straight into checkout on the exact product with a promo applied.
🎯 Precise campaign targeting
One campaign can promote Tour A and another Tour B, each with its own link:
A
?openWidget=1&productID=TOUR_A&promoCode=SPRING10
B
?openWidget=1&productID=TOUR_B&promoCode=VIP25
🧪 Cleaner A/B testing
Results are attributable to the exact link variant.
⚙️ Operational simplicity
No new landing pages required per offer.
One generic page + many smart links.