APIs & Integrations

RiccardoPisani
Top Contributor

Javascript event

Hi there,

 

I would like to create a custom event thru a Javascript that fires when a visitor scrolls my page at a certain point/it can also be at a certain percentage of the page.

 

Anyone that already has been thru this/would like to help

 

Thanks a ton in advance

Riccardo

0 Upvotes
2 Replies 2
lscanlan
HubSpot Alumni
HubSpot Alumni

Javascript event

Hi Riccardo,

 

I haven't specifically done this, but I would imagine it's just a combination of using our JavaScript Events API along with a JavaScript event handler for when the page gets scrolled to a specific element or pixel height. So the first part of this is figuring out how to fire an event at a specific page scroll. I found this thread on Stack Overflow: https://stackoverflow.com/questions/21561480/trigger-event-when-user-scroll-to-specific-element-with..., where you can use jQuery to listen for when a page is scrolled to a specific element.

 

Once you've got the event handler set up, you'd trigger the actual event: https://developers.hubspot.com/docs/methods/tracking_code_api/javascript_events_api.

 

If you have any trouble setting it up, feel free to link me to a page where you're having trouble and I'll be happy to look.

 

Thanks,
Leland

Leland Scanlan

HubSpot Developer Support
0 Upvotes
RiccardoPisani
Top Contributor

Javascript event

Hi there Leland, I will go thru this solutions and let you know.

 

In the maintime, thanks for sharing this.

 

Kind regards,
Riccardo