I recently read this guide on how to add an event listener for when someone books a meeting, but I saw it was from 4 years ago so I went to check if the event.data objects were accurate but couldn’t find any docs on event.data. I was able to log the object coming through but can someone point me in the right direction for when I need to do something else with the event.data?
Hey, @ECupaioli
Welcome to the community. I agree with you, using older resources can be help, but they run the risk of becoming obsolete or outdated.
The specifics of what is included in event.data can vary depending on the specific API or platform you’re using. Without more information on the specific endpoint you’re using, it’s hard to provide guidance. Would you mind sharing more details about what you are using? That might help us to provide more targeted advice.
Probably not a solution, but you might consider messing around with JavaScript’s console.dir(event). It allows you to interactively explore all properties of the event object in your browser’s console.
Have fun building! — Jaycee
I’m using the Meeting Scheduler widget . There’s an ad landing page and an API page for how to build your own, but nothing really on the widget and how to use event listeners with it. This is the code from the guide that works for me but I’m not clear on how that person got that info. It’s the wisdom of the ancients without any proper docs.
Hi @ECupaioli ,
Here is the code I use to send data from the meeting tool to Tagmanager:
<script type="text/javascript">
window.dataLayer = window.dataLayer || [];
window.addEventListener('message', event => {
if (event.data.meetingBookSucceeded) {
window.dataLayer.push({
event: 'hubspotBookedMeeting',
currentUrl: window.location.href,
hsFormGuid: event.data.meetingsPayload.formGuid,
paidMeeting: event.data.meetingsPayload.isPaidMeeting,
linkType: event.data.meetingsPayload.linkType,
offline: event.data.meetingsPayload.offline,
});
}
});
</script>
Hope this helps!
I created a video about HubSpot events and GA4, but it also explains a bit about the meeting tool (around 4 min).
Thank you, @Teun! You’re a legend
And thank you to @EdCupaioli for the Wisdom of the Ancients reference. I needed a good lol/sob – Jaycee
I posted the article I got a very similar solution from. I’m sure your solution works fine too, however my question was regarding the API documentation you used to find that solution. I can’t find any docs on the event.data response. How would you have known listen for that response? I’m assuming you read some docs from hubspot or the lords of hubspot appeared in a burning bush to reveal their secrets. I’m hoping the former is true so I can create solutions in the future much like you did since I don’t learn anything from just copy pasting solutions.
Hi @EdCupaioli ,
Fair point, and mate, do you make me laugh!
Sadly, there isn’t any documentation about window events besides the form events. I simply went with testing and using console logs to see what I can use.
As you can see, there is no result in Google available;
I also found this solution using the logs specific to CTA forms since they post a different message: https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/td-p/767234