If you experience any trouble or have any questions, please give us a call: +1 248.471.6777
// Execute this function on the confirmation booking success page
function onBookingSuccess() {
// HubSpot API key
const hubspotApiKey = 'pat-na1-c15f035d-f5ac-4a93-a97b-ba788f874a83';
// Get contactId and dealId from the URL, assuming they are passed as URL parameters
const urlParams = new URLSearchParams(window.location.search);
const contactId = urlParams.get('contactId');
const dealId = urlParams.get('dealId');
if (contactId && dealId) {
// Update deal stage to "success" (Replace 'your-success-deal-stage-id' with your success deal stage ID)
fetch(`https://api.hubapi.com/deals/v1/deal/${dealId}?hapikey=${hubspotApiKey}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
properties: [
{
name: 'dealstage',
value: 'your-success-deal-stage-id', // Replace with your actual success deal stage ID
},
],
}),
})
.then((response) => {
if (response.ok) {
console.log('Deal stage updated successfully');
} else {
console.error('Error updating deal stage:', response.statusText);
}
})
.catch((error) => {
console.error('Error updating deal stage:', error);
});
}
}
// Call the function on page load
$(document).ready(onBookingSuccess);
Copyright © Zap Zone 2022. All Right Reserved.