---
slug: sdk-api
title: "What does the tracking SDK offer?"
category: installation
locale: en
updated: 2026-10-19
keywords: ["SDK","JavaScript","API","track","identify","conversion"]
questions: ["Which JavaScript calls are available?","JavaScript API","metrunio.track","How do I send a custom event?","SDK documentation","What happens to calls before the SDK has loaded?","What is metrunioQueue?"]
url: https://metrunio.com/en/help/sdk-api
---

# What does the tracking SDK offer?

**Which JavaScript calls are available?**

The SDK provides init, setConsent, page, track, identify, conversion, goal and reset, plus paymentReference for Stripe and PayPal, fillForm for forms, and renderSurvey and survey for the post-purchase question. It loads asynchronously and sends events in batches. Until it has loaded, the embed code takes the calls and only keeps a measurement call if your page has reported matching consent beforehand.

```javascript
metrunio.init({ siteId, writeKey, endpoint, consent, autoPageviews, testMode, debug });
metrunio.setConsent({ analytics: true, marketing: true });
metrunio.page({ area: 'home' });
metrunio.track('add_to_cart', { product: 'abc', price: 24.9 });
metrunio.identify('customer-4711');
metrunio.conversion({ orderId: '12345', value: 149.9, currency: 'EUR' });
metrunio.goal('shop_created'); // funnel step, counts once per customer
metrunio.paymentReference(); // reference for Stripe and PayPal, only with consent
metrunio.renderSurvey('#metrunio-frage', { orderId: '12345' }); // post-purchase question on the thank-you page
metrunio.survey({ orderId: '12345', answer: 'podcast_radio' }); // answer from your own interface
metrunio.fillForm('#enquiry'); // lead ID and origin into the form
metrunio.reset();
```

## Behaviour

- Asynchronous loading; calls made before it loads go into window.metrunioQueue and are replayed afterwards.
- Before the SDK loads, the embed code already checks every call. It remembers the decision from setConsent or init({ consent }) and keeps page, track, identify, conversion and goal only with analytics or marketing consent, renderSurvey, survey and fillForm only with analytics, advertising events only with marketing. Without it, the call is dropped straight away with all its details, even if the SDK loads slowly or not at all. A withdrawal also drops what it already holds, and later consent does not catch anything up. init, setConsent and reset are always kept.
- If you copied the embed code before 19 October 2026, it holds every call until the SDK has loaded, even without consent. Copy it again from the portal under “Setup”. The new one sets metrunio.v to 2.
- Batched sending: ten events or 1.5 seconds by default; navigator.sendBeacon when the page unloads.
- Up to three retries with backoff; after that the batch stays local and is resent on the next page view.
- The event ID is created before sending, so retries stay idempotent.
- Without marketing consent, advertising events never leave the device.
- No fingerprinting: the pseudonymous ID is a random first-party value in local storage.
- A custom event gets its name through `event_name`: `metrunio.track('custom', { event_name: 'newsletter_signup' })`. Letters, digits and `_ . : -`, at most 64 characters; that is how it appears in a journey’s visit history.

## Console error codes

| Code | Meaning |
| --- | --- |
| CONFIG_INCOMPLETE | siteId, writeKey or endpoint missing, or the placeholder still stands in place of the write key |
| DOUBLE_INIT | init() called a second time, usually because of a double installation; the first call applies |
| NOT_INITIALIZED | call before init() |
| CONVERSION_ORDER_ID_MISSING | purchase without an order number |
| GOAL_KEY_MISSING | funnel step without a key |
| GOAL_KEY_INVALID | key with spaces, accented letters or special characters other than _ . and -, or longer than 64 characters; the SDK lowercases capital letters itself |

> **Note:** debug: true logs every SDK decision to the browser console. That is particularly useful for seeing why an event was not sent for lack of consent.

## Also asked

- JavaScript API
- metrunio.track
- How do I send a custom event?
- SDK documentation
- What happens to calls before the SDK has loaded?
- What is metrunioQueue?

## Related

- https://metrunio.com/en/help/snippet-einbauen
- https://metrunio.com/en/help/single-page-app
- https://metrunio.com/en/help/welche-events-gibt-es
- https://metrunio.com/en/help/funnel-schritte-einbauen
- https://metrunio.com/en/help/nachkauf-frage
- https://metrunio.com/en/help/herkunft-im-formular
