Metrickle

Send events from Segment or RudderStack

Last updated

If your events already go through Segment or RudderStack, you can send them to Metrickle without adding its script. Both platforms forward their calls to a webhook destination, and Metrickle turns them into its own events. Pageviews, screens, custom events, revenue, refunds and sign-ins all work from a source alone, so goals, funnels, journeys, retention, revenue and task success do too.

Set it up

  1. Open the app's Integrations page and find Event sources. You need to be an owner or admin, or have the apps.keys permission.
  2. Choose Segment or RudderStack. Each app has one source per platform, with its own endpoint URL and secret.
  3. Add a webhook destination in Segment or RudderStack with that URL and secret (see below). Use the destination's default payload, the whole event, not a custom mapping.
  4. Send a test event. The source shows the last event it received and anything it dropped.

Anyone with the secret can add events to the app, so keep it only in your destination's settings.

Endpoint and secret

POST https://in.metrickle.com/v1/sources/src_…

Send the secret (mk_src_…) in one of these ways:

  • An x-metrickle-secret header. Use this with Segment's Webhooks (Actions) destination and RudderStack's Webhook destination, under Headers.
  • Segment's classic Webhooks destination, with the secret as its Shared Secret. Metrickle checks the X-Signature header.
  • Authorization: Bearer mk_src_…, or Basic auth with the secret as the user name or the password.

The body can be one message, an array of messages, or the batch format { "batch": [...] }: up to 500 messages and 512 KB.

ResponseMeans
200 { "ok": true, "accepted": 12, "dropped": {...} }Read. dropped counts messages that weren't stored, by reason. Not retried
400Not JSON, or more than 500 messages
401Wrong or missing secret or signature
404No such source, or the app was archived
413Body over 512 KB
429Rate limited. Both platforms send it again

How calls are mapped

CallBecomes
pageA $pageview with path, address (without the query string), title and referrer. UTM tags come from context.campaign, then the address
screenA $screen, with the screen name as its path and title, as the native SDKs send it
trackA custom event named after event, with its properties. Nested objects and arrays are kept as JSON when they fit in 1,024 characters. A leading $ is removed, since $ names are Metrickle's own
identifyA sign-in linking anonymousId to userId, as identify() in the SDK does. Traits that name a person directly, such as email, name, phone, address, birthday or username, aren't stored
aliasLinks previousId to userId. Only an anonymous id can be linked to a user, not one user id to another
groupA $group event with the group's id and traits, without traits that name a person

Revenue

Revenue follows Segment's ecommerce spec:

  • Order Completed: revenue, else total, else value, else the sum of each product's price times quantity.
  • Order Refunded: the same amount, stored as negative revenue. It takes back the task completion it undoes, like a refund from the SDK. A refund without an amount can't be negative revenue, so make Order Refunded the task's revoke step instead.
  • Any other event: a numeric revenue property, as with the SDK.

Other fields

  • context.library and context.os decide the platform: web, iOS, Android, React Native, Flutter, or server for server libraries.
  • For web calls, context.userAgent gives the browser, operating system and device type.
  • context.app.version, context.screen, context.locale and RudderStack's context.sessionId are used when present. Without a session id, a session is each 30-minute period of a visitor's activity.
  • timestamp is used as sent, since both platforms correct the sender's clock. Times in the future are moved to now.
  • Use the same opaque user ids in your source and in any Metrickle SDK, so their events join up into one person.

What a source can't send

A source forwards what your code tracks. It doesn't run on the device, so these need Metrickle's script or SDK as well:

Needs the SDKWhy
Friction: rage, dead and error clicks, u-turns, form errors and abandonmentDetected from clicks, taps and form state on the device
Accessibility settings: screen reader, keyboard, zoom, large text, reduced motionRead from the browser's or phone's settings. Events from a source have none, so they fall in the none group and protected flows can't judge them
Session replay, heatmaps and page snapshotsRecorded in the browser
Surveys, problem reports and study tasksShown on the device
Web vitals, script errors, outbound clicksMeasured in the browser
Visitor locationRequests come from Segment's or RudderStack's servers. Only a country code you put in context.location.country is used

What is dropped

Each message is checked in turn. It's counted under dropped instead of stored when:

ReasonWhen
call_offThat call type is turned off for this source
opted_outintegrations.Metrickle is false, or integrations.All is false without Metrickle, Webhook, Webhooks or Webhooks (Actions) turned back on
no_consentThe source requires consent and the message doesn't grant every listed category
botA browser call from a crawler or headless browser. Server libraries aren't checked
originA browser call from a page outside the app's allowed origins
too_oldMore than 7 days old. It's dropped rather than moved, so a replayed backfill can't pile onto one day
invalid, unsupportedNot a message, missing what its call needs (an event name, a user id, a screen name, a group id), or another call type

When a workspace is far over its plan's monthly events, a steady share of visitors is kept, as with the HTTP ingest API.

By default a source stores every event (Store every event). Use this when your Segment or RudderStack consent setup already decides what reaches Metrickle. To check consent in Metrickle instead, choose Only events with consent and list the categories that must be granted:

  • Segment: category names from context.consent.categoryPreferences, such as Analytics.
  • RudderStack: consent ids from context.consentManagement.allowedConsentIds, such as C0002 for OneTrust performance cookies. An id in deniedConsentIds counts as refused.

A message is kept only when every listed category is granted and none is refused. A message without consent fields is dropped. Matching ignores case.

Use a source and the SDK together

Run the SDK for what only it can see, and the source for what your servers already send. To avoid counting anything twice:

  1. Pick one sender for each call. With the script or an SDK installed, turn off Page and Screen under the source's Calls to accept, since the SDK records them with friction and accessibility settings. Keep Track for events the SDK doesn't send, usually server-side ones such as Order Completed, Order Refunded and Subscription Cancelled.
  2. Use the same user id in both, so the device's events and the server's events join up into one person.
  3. Rely on messageId for repeats. Each message's messageId becomes its event id (or an id made from it, when it isn't a UUID), so retries, Segment replays and the same message arriving through both platforms are stored once. Metrickle can't tell that an SDK pageview and a page call describe the same view, which is why step 1 matters.

If you also post to the HTTP ingest API from your servers, give the event the same UUID as the message's messageId (when that's a UUID) and they won't be stored twice.