Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thmsobrmlr/a6ce89ee577ee3f8f5e6f8ed599e5a23 to your computer and use it in GitHub Desktop.
Save thmsobrmlr/a6ce89ee577ee3f8f5e6f8ed599e5a23 to your computer and use it in GitHub Desktop.
Track conversions of Hubspot Meetings (iframe)
function isHubspotUrl(url) {
var hubspotUrls = [
'https://local.hubspot.com',
'https://app.hubspotqa.com',
'https://app.hubspot.com',
'https://meetings.hubspot.com'
];
return hubspotUrls.indexOf(url) > -1
}
// hubspot meetings uses postMessage api to send various events
function receiveMessage(event) {
if (isHubspotUrl(event.origin) && event.data.meetingCreated) {
console.log('hubspot meetings: meetingCreated event');
}
// there is a typo in the event fired by hubspot. `meeetingBookSucceeded` is the correct attribute to watch for.
if (isHubspotUrl(event.origin) && event.data.meeetingBookSucceeded) {
console.log('hubspot meetings: meeetingBookSucceeded event');
}
}
window.addEventListener('message', receiveMessage)
@jurStv
Copy link

jurStv commented Jun 30, 2018

Thanks!

@timelf123
Copy link

Still working for you @Thomas88 ?

@AgilePixelStudio
Copy link

Hi. can i have some more info on how to get this to work? I am so annoyed that hubspot requires crazy workarounds when all they need to do is let us customize the meetings thank you page!

@fbonawiede
Copy link

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment