Use the API Unlock template to trigger advanced user actions and verify entries in real time using a custom Javascript tracking script.
Use the API Unlock template to trigger advanced user actions and verify entries in real time using a custom Javascript tracking script.
This template is designed for developers and advanced users who need to track on-site actions that cannot be verified through standard URL visits or social integrations. Use it to unlock powerful API-based triggers such as form submissions, gated pages, profile completions, or custom user flows.
Simply configure the action in Gleam, embed the tracking script on your website or app, and automatically verify when a specific user completes the required task.
gleam.track()
This feature is built for flexibility, allowing you to integrate Gleam into unique workflows, microservice architectures, or advanced tracking setups.
Adding tracking to your campaign allows you to:
Whether you are building custom journeys, capturing events via webhooks, or layering contests into your SaaS app, API tracking gives you the freedom to tailor Gleam to your architecture.
This template requires basic knowledge of JavaScript and access to your website's codebase. To trigger actions, use the following syntax in your code:
gleam.track('custom_action_name');
Replace 'custom_action_name'
with the name of the action configured in your campaign.
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.
Embed the Gleam script, then use gleam.track('your_action_name') on form submission or other behaviors. Expand this FAQ to see where and how to implement it properly.
Use API Unlocks when the user action happens outside of a standard link click or visit. Click to learn when this method is best for SaaS, forms, or app interactions.
Create a Custom Action
In your Gleam campaign, add a Custom Action and give it a clear action name. This will be used to match your tracking event from the frontend.
➡ Learn how to set up a Custom Action
Set Up API Tracking Script
Embed the Gleam tracking code on the page where the user action should be verified — such as a profile update page, form confirmation, or thank-you screen.
Use the following snippet to track the custom action:
‘gleam.track('your_action_name');’
Replace 'your_action_name'
with the exact name of your Custom Action from Step 1.
➡ API Tracking Script Reference
Configure Custom Fields (Optional)
You can extend your action with custom fields to sync form input or capture data directly to your CRM.
➡ Learn how to sync fields
Connect Integrations for Advanced Logic
Gleam supports integration with major platforms and custom workflows via Webhooks or REST endpoints.
➡ See integration options
Finalise and Test Your Campaign
Publish your campaign and simulate the tracked action to ensure it fires correctly. You can inspect the real-time validation in your Gleam dashboard under the Actions tab.
➡ How to install your Gleam campaign
This setup is ideal for users who need complete control over the user journey and prefer validation via embedded tracking scripts rather than standard URLs or buttons.
Use the API Unlock template to trigger advanced user actions and verify entries in real time using a custom Javascript tracking script.