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

Yes. Custom Action Tracking works in single page apps and headless sites, because you fire it from your own JavaScript.

  1. Set up a Custom Action with tracking and give it a tracking name, such as Signup.
  2. Load your campaign's tracking script once, in the <head> of your app shell.
  3. Fire the trigger when the thing actually happens, for example after your router finishes a page change or your form's success callback runs:
<script>
  window.Gleam = window.Gleam || [];
  Gleam.push(['Signup']);
</script>

Calls made before the script has loaded are queued and sent once it loads, so load order won't lose an event. Fire it from your app code rather than relying on a page load, since SPA routes don't reload the page.

There's no gleam.track() function. The call is Gleam.push. Custom Action Tracking is on the Business Plan and above.

What Is API Tracking In A Giveaway?

API tracking verifies custom user actions on your site, like signups or profile updates, using Gleam’s JavaScript API. Expand to learn how gleam.track() lets you track more than just link clicks.

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

Add a Custom Action with a tracking name, install your campaign's tracking script, then fire Gleam.push with that name when the event happens.

See Next Article

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

Add a Custom Action with a tracking name, install your campaign's tracking script, then fire Gleam.push with that name when the event happens.