Appearance
JavaScript API
All calls go through the global ah(...) function. They are queued until the script loads.
| Call | Effect |
|---|---|
eureka('config', {...}) | Set options before start. See installation options. |
eureka('event', name, params) | Custom event. String params become properties, numbers become numeric properties. |
eureka('purchase' | 'add_to_cart' | …, params) | Ecommerce shortcut with GA4-shaped params. See Ecommerce events. |
eureka('page_view', props?) | Manual page view, for single-page apps with page autocapture off |
eureka('set', props) | Global string properties added to every following event |
eureka('identify', id) | Business user ID. Hashed with SHA-256 in the browser and sent only in full mode. A 64-character hex value is treated as already hashed. |
eureka('consent', value) | Consent decision: 'granted', 'denied', {analytics, ads, personalization}, or a mode 'full', 'cookieless', 'none' |
eureka('optout') / eureka('optin') | optout stops all collection, deletes _ah_id, _ah_s and the outbox, and sets _ah_optout=1 for 13 months. optin removes it. |
eureka('actor', 'ai_agent', 'my-agent') | Manual actor override, for example for an agent your site authenticated itself. eureka('actor') clears it. |
eureka('flush') | Send queued events now |
eureka('debug', true) | Log events to the console |
Examples:
js
// A lead form was sent
eureka('event', 'generate_lead', { form: 'contact', topic: 'pricing', value: 1 })
// The visitor logged in
eureka('identify', 'user-42')
// Your CMP callback
eureka('consent', { analytics: true, ads: false, personalization: false })
// A partner agent you authenticated through your own API
eureka('actor', 'ai_agent', 'acme-shopping-agent')Event names are lower snake case ([a-z0-9_], up to 64 characters).