Skip to content
metryo

01Quick start

Install Metryo in minutes.

Create a website in your dashboard, copy your snippet, and paste it before the closing </head> tag. Data appears within seconds of the first visit.

index.html
<!-- Add before the closing </head> tag -->
<script
  defer
  data-site="site_xxxxx"
  src="https://cdn.metryo.io/m.js">
</script>

Replace site_xxxxx with the site ID from your dashboard — everything else is copied as-is.

02Custom events

Track the actions that matter.

Pageviews are automatic on every plan. For everything else — signups, purchases, downloads — call metryo.event() from anywhere in your code. Available on all plans, including Free.

From JavaScript

anywhere.js
// Track any action with one call — from an onclick,
// a form submit, or anywhere in your code.
metryo.event("Signup completed");

// Attach properties (strings, numbers, booleans):
metryo.event("Checkout started", {
  plan: "growth",
  value: 15,
});

From HTML

index.html
<button onclick="metryo.event('Pricing CTA clicked')">
  Start for free
</button>

Single-page apps

spa.js
// Nothing to do — the script hooks history.pushState and
// popstate, so client-side route changes are tracked
// automatically. To send one manually:
metryo.pageview();

03Click tracking · Paid plans

Measure clicks without writing code.

On any paid plan the script also records clicks on its own. Mark an element with data-metryo-event and it is tracked by name; outbound links and file downloads are detected with no markup at all.

Click tracking is available from the Starter plan upwards. On the Free plan these events are discarded and never count towards your monthly allowance — metryo.event() keeps working on every plan.

Naming a click

index.html
<!-- Name a click yourself: no JavaScript needed -->
<button data-metryo-event="Add card">
  Add card
</button>

<!-- Attach properties with data-metryo-prop-* -->
<button
  data-metryo-event="Signup started"
  data-metryo-prop-plan="growth"
  data-metryo-prop-position="hero"
>
  Start for free
</button>

<!-- Opt an element out entirely -->
<a href="https://example.com" data-metryo-ignore>Ignored</a>

Detected automatically

  • Outbound link — any link to a different hostname, with the destination domain, full URL and link text as properties.
  • File download — links ending in a document, archive, installer or media extension, with the file name attached.
  • In-page anchors and mailto: or tel: links are skipped, so they never consume your allowance.

Turning detection off

head.html
<!-- Keep marked elements only: no outbound or download
     tracking -->
<script
  defer
  data-site="site_xxxxx"
  data-auto-clicks="off"
  src="https://cdn.metryo.io/m.js">
</script>

04Reference

The collect endpoint.

The script sends a tiny JSON payload to POST /api/collect. You can also call it directly from native apps or server-side code.

FieldTypeDescription
sstringYour site ID, e.g. site_k3v9x2m4q1 (required)
ustringFull page URL, including query string (required)
rstringdocument.referrer, may be empty
w / hnumberScreen width and height in pixels
estring?Custom event name — omit for a pageview
pobject?Event properties (strings, numbers, booleans)
tstring?"click" for auto-tracked clicks — requires a paid plan

The endpoint always answers 202 so analytics can never break your page. Device, browser, country and traffic-quality signals are derived server-side; the visitor identifier is a salted hash that rotates monthly — no cookies, no raw IP stored.