---
slug: sdk-api
title: "What does the tracking SDK offer?"
category: installation
locale: en
updated: 2026-10-13
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"]
url: https://bench.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, queues calls made before it loads, and sends events in batches.

```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.
- 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

## Related

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