How Do I Use Gleam to Track Custom Actions With JavaScript?

Gleam lets you track actions that don’t happen through a standard click or built-in integration. This is useful when you want to reward users for behaviors that happen inside your own website or app.

To track a custom action with JavaScript:

  • Add the Gleam embed script to your site
  • Create a Custom Action inside your campaign
  • Trigger gleam.track('your_action_name') when the action is completed

Advanced tracking setup showing custom JavaScript action tracking

This works well for things like:

  • JavaScript form submissions
  • Video completions
  • Onboarding milestones
  • Quiz or tool interactions
  • Other in-app events that aren’t tied to a simple URL visit

You can also pass optional metadata when needed, which is useful for tracking variations or different completion contexts.

Custom JavaScript tracking is valuable because it lets you reward real engagement even when the action happens outside Gleam’s standard action flow.

For implementation details and sample code, see the API Tracking documentation.

See Next Article

Can I Use Gleam API Tracking With a Headless CMS or SPA?

Yes—gleam.track() works with Single Page Applications and headless setups. Expand this FAQ to learn the best way to implement it with dynamic page states.