JavaScript API
The Grona website script exposes one public command on window: grona('track', ...), which sends a conversion. This page is the reference for that command, the queue stub that lets you call it before the script loads, and what the script does not offer.
grona('track', eventName, data)
Section titled “grona('track', eventName, data)”Sends a conversion for the current visitor.
grona(command: 'track', eventName: string, data?: object): void| Argument | Type | Description |
|---|---|---|
command |
'track' |
The only supported command. Any other value logs an “Unknown command” warning in the console and does nothing. |
eventName |
string | The goal’s event name, as set up in the dashboard, such as purchase or signup. |
data |
object, optional | Free-form details about the conversion. Defaults to {}. |
The call returns nothing and does not throw. If the conversion cannot be sent, for example in preview mode or before the visitor has consented, the call does nothing and may log a message to the console.
The shape of data
Section titled “The shape of data”data is any plain object. Grona stores its fields with the conversion. Four field names have a meaning: order_id, order_code, order_number and booking_id hold an order or booking code, and Grona counts the goal once per code. See De-duplication.
grona('track', 'purchase', { order_id: 'ord_58213', currency: 'USD', items: ['sku_10432', 'sku_31005'],});Do not put personal data such as email addresses, phone numbers or names in data. If you include a customer reference, use an opaque id such as cus_7Hq2Lm9x.
The queue stub
Section titled “The queue stub”main.js loads asynchronously. To call grona() before it has loaded, define this stub first, once per page:
<script> window.grona = window.grona || function () { (window.grona.q = window.grona.q || []).push(arguments); };</script>The stub stores each call’s arguments on window.grona.q. When the runtime starts, it replaces window.grona with the real function and replays the queued calls in order. Calls made after that go straight to the real function.
What is not available
Section titled “What is not available”The website script has no other public API.
- No other commands.
grona()accepts only'track'. There is no command to identify a visitor, set a visitor id for a signed-in user, set attributes, force a variation or re-run campaigns. - No events or callbacks. The script dispatches no DOM events and offers no callback for “variation applied” or “campaign enrolled”. There is no built-in push of assignments to Google Analytics or other analytics tools.
- No consent API. There is no function or flag to tell Grona about consent. Grona reads consent from the consent tools it supports. See Consent platforms.
- No public globals. The script sets other
windowproperties for its own use. They are internal, can change without notice, and are not part of this API. One of them,window.QueryParams, is not namespaced, so it can collide with a global of the same name on your site.