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
- Open the app's Integrations page and find Event sources. You need to be an owner or admin, or have the
apps.keyspermission. - Choose Segment or RudderStack. Each app has one source per platform, with its own endpoint URL and secret.
- 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.
- 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-secretheader. 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-Signatureheader. 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.
| Response | Means |
|---|---|
200 { "ok": true, "accepted": 12, "dropped": {...} } | Read. dropped counts messages that weren't stored, by reason. Not retried |
400 | Not JSON, or more than 500 messages |
401 | Wrong or missing secret or signature |
404 | No such source, or the app was archived |
413 | Body over 512 KB |
429 | Rate limited. Both platforms send it again |
How calls are mapped
| Call | Becomes |
|---|---|
page | A $pageview with path, address (without the query string), title and referrer. UTM tags come from context.campaign, then the address |
screen | A $screen, with the screen name as its path and title, as the native SDKs send it |
track | A 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 |
identify | A 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 |
alias | Links previousId to userId. Only an anonymous id can be linked to a user, not one user id to another |
group | A $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, elsetotal, elsevalue, 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 Refundedthe task's revoke step instead. - Any other event: a numeric
revenueproperty, as with the SDK.
Other fields
context.libraryandcontext.osdecide the platform: web, iOS, Android, React Native, Flutter, or server for server libraries.- For web calls,
context.userAgentgives the browser, operating system and device type. context.app.version,context.screen,context.localeand RudderStack'scontext.sessionIdare used when present. Without a session id, a session is each 30-minute period of a visitor's activity.timestampis 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 SDK | Why |
|---|---|
| Friction: rage, dead and error clicks, u-turns, form errors and abandonment | Detected from clicks, taps and form state on the device |
| Accessibility settings: screen reader, keyboard, zoom, large text, reduced motion | Read 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 snapshots | Recorded in the browser |
| Surveys, problem reports and study tasks | Shown on the device |
| Web vitals, script errors, outbound clicks | Measured in the browser |
| Visitor location | Requests 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:
| Reason | When |
|---|---|
call_off | That call type is turned off for this source |
opted_out | integrations.Metrickle is false, or integrations.All is false without Metrickle, Webhook, Webhooks or Webhooks (Actions) turned back on |
no_consent | The source requires consent and the message doesn't grant every listed category |
bot | A browser call from a crawler or headless browser. Server libraries aren't checked |
origin | A browser call from a page outside the app's allowed origins |
too_old | More than 7 days old. It's dropped rather than moved, so a replayed backfill can't pile onto one day |
invalid, unsupported | Not 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.
Consent
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 asAnalytics. - RudderStack: consent ids from
context.consentManagement.allowedConsentIds, such asC0002for OneTrust performance cookies. An id indeniedConsentIdscounts 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:
- 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 RefundedandSubscription Cancelled. - Use the same user id in both, so the device's events and the server's events join up into one person.
- Rely on
messageIdfor repeats. Each message'smessageIdbecomes 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 apagecall 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.