Unagi/Docs

Documentation /

Tracking orders and custom events

Most things are detected automatically. Use the methods below when you need exact values or want to record something Unagi cannot see. All of them require consent (see consent); without it they do nothing.

Purchases with exact values

If your order-confirmation page URL contains words like thank-you or order-confirmation, Unagi records a purchase automatically, but without a value. For revenue figures, call this once the order is confirmed:

Unagi.track('purchase', { value: 49.99, currency: 'GBP', order_id: 'A1234' });

If you do this, the automatic purchase for that page is skipped, so orders are not counted twice. Do not include customer names, emails or addresses.

Built-in event names

Unagi.track(name, properties) recognises these names: cart_add, cart_remove, checkout, purchase and search (with { term: '…' }). Any other name is stored as a custom event with the name in its properties.

Unagi.track('cart_add', { productPath: '/products/ring' });
Unagi.track('newsletter_signup', { location: 'footer' });

Without writing JavaScript

Add attributes to any element and Unagi records a click on it:

<button data-unagi-event="cart_add" data-unagi-props='{"productPath":"/products/ring"}'>
  Add to bag
</button>

Limits and what is dropped

Other methods

CallEffect
Unagi.consent(true|false)Records the visitor's consent choice.
Unagi.reset()Forgets this visitor in this browser (ID, session and saved consent).