Skip to main content

How to count Segment events from Segment's servers

Send Segment events to Mida through Segment's Webhooks destination, so events that fire before the Mida tag loads are still counted.

If you use Segment, Mida can count your Segment track events, such as a purchase or a signup, as goals in your A/B tests. Any event name works, including your own custom events. By default Mida hears them in the visitor's browser, on pages where the Mida tag is running. This article explains a second way: Segment sends each event to Mida from its own servers.

When to use this

Turn this on when some of the events you care about never reach Mida in the browser. Common cases:

  • Events that fire as a page opens. Mida hears a Segment event in the browser only after the Mida tag has loaded on that page. An event sent earlier, such as a confirmation fired on page load, is missed.

  • Events on pages without the Mida tag. For example a checkout or app on another part of your site, as long as Segment uses the same anonymous ID there.

  • Events from your servers. For example a payment confirmed by your backend through a server-side Segment source, as long as the event carries the visitor's anonymous ID or user ID.

Missed events make results less accurate. If they are missed more often on one variant's pages than the other's, they can make that variant look worse than it is.

How it works

  • Whenever the Mida tag runs on a page, it tells Mida which Segment ID belongs to the visitor: the anonymous ID, and the user ID once you have identified them (never an email address).

  • Segment's Webhooks destination sends each track event to Mida.

  • Mida matches the event to the visitor by the anonymous ID, or by the user ID, and records it exactly as if it had come from the browser. Goals, reports and plan limits work as before.

  • While this is on, Mida stops reading Segment events in the browser, so an event is never counted twice. Segment retrying the same event is also counted once.

The tag only has to load once for a visitor, on any page, for their later events to be matched, wherever those events come from.

Before you start

  • The Segment integration is enabled in Mida (Integrations, Segment).

  • You can add a destination to your website source in Segment.

  • The Mida tag is installed on your site.

  • You are an Owner or Admin in Mida.

Set it up

In Mida

  1. Open Integrations and choose Segment. Make sure it is enabled.

  2. Open the Config tab and tick Count Segment events from Segment's servers.

  3. Copy the webhook URL shown below the switch. Keep it private: anyone with it can send events to your project.

In Segment

  1. Open Connections, then Destinations, and add the Webhooks (Actions) destination to your website source.

  2. Add a Send mapping that triggers on Track events.

  3. Set the method to POST and paste the URL from Mida. Leave the data as the whole event. Batching can be on or off.

  4. Save the mapping and turn the destination on.

Check that it works

Back on the Segment Config tab in Mida, you can see when the last event arrived, and for the last 7 days how many events were matched to a Mida visitor and how many could not be. New events usually appear within a minute.

Which events are matched

Event

Matched?

A track event from a visitor whose browser loaded the Mida tag in the last 180 days

Yes

An event that fired before the Mida tag loaded, or on a page without the tag

Yes, if the tag loaded for that visitor at any point and Segment used the same ID

An event from your servers (a server-side Segment source) that carries the visitor's anonymous ID or user ID

Yes

An event from someone who never loaded the Mida tag, or who blocks it

No. It is counted as "could not be matched".

Page, identify and other non-track calls

No. They are ignored.

Mida's own events (mida_pageview, mida_execute, mida_conversion) that Segment sends back

No. Mida already has them, so they are ignored.

If the tag has not reported a visitor yet when their event arrives (both often happen on the same page view), Mida looks again over the next two minutes before giving up on it.

Privacy

  • Mida keeps the link between a visitor and their Segment anonymous ID and user ID for 180 days, only to match events. User IDs are stored hashed. A user ID that is an email address is never sent to Mida.

  • If you use Strict Consent Mode, the tag reports nothing until the visitor gives consent.

  • Mida records the event name, its properties and the page, as it does for events from the browser.

Turn it off

Untick Count Segment events from Segment's servers in Mida. Mida then ignores events from the webhook and goes back to reading them in the browser. Turn off or remove the Webhooks destination in Segment too.

Troubleshooting

What you see

What to check

No events received yet

Check that the Webhooks destination is on, that the mapping triggers on Track events, and that the URL is exactly the one from Mida.

Many events could not be matched

Those visitors never loaded the Mida tag in that browser, for example because it is blocked or consent was not given. Check the tag is installed on the pages people visit before the event.

Segment shows an error saying to turn on the setting

The switch in Mida is off. Tick it on the Segment Config tab.

Segment shows a 401 error

The URL is wrong or belongs to another project. Copy it again from Mida.

FAQ

Do I still need the Segment integration enabled in Mida?

Yes. This only changes how Segment events reach Mida. Sending Mida's own experiment events to Segment works as before.

Do my goals need to change?

No. Events keep their Segment names, so goals set up on them keep working.

Will past events be added?

No. Mida counts events from the moment the destination is on.

Did this answer your question?