githubEdit

Scroll-Triggered Widget

Show the Alhena chat widget only after the user scrolls down the page, reducing initial visual clutter.

This example shows how to hide the chat widget on initial page load and only show it after the user scrolls down. This is useful for landing pages or content-heavy sites where you want to minimize distractions while still offering support.

What You'll Learn

  • Hide the widget on initial page load using CSS

  • Detect scroll events

  • Show the widget after a scroll threshold

  • Control widget visibility programmatically

Use Case

Showing the chat widget immediately can:

  • Distract users from your content

  • Increase perceived page load time

  • Feel intrusive on landing pages

By delaying the widget until the user scrolls, you:

  • Let users engage with your content first

  • Indicate the user is actively browsing

  • Show support when it's more likely to be needed

Code Example

How It Works

  1. CSS hiding: The #helix-chat-container element is hidden with display: none

  2. Scroll listener: We listen for scroll events on the window

  3. Threshold check: When scroll position exceeds the threshold (100px by default), show the widget

  4. One-time trigger: Remove the scroll listener after showing to avoid unnecessary checks

  5. Fallback timeout: Show the widget after 30 seconds even without scroll (for users who don't scroll)

Customization Options

Change scroll threshold

Adjust when the widget appears:

Show based on percentage of page

Show when reaching a specific element

Add with manual buttons

With Event Logging

Track widget events for analytics:

Complete Example with All Features

Last updated