Skip to main content
10 minIntegration

Segment Integration

Enrich identified users automatically with a Segment destination function and route enriched data to your warehouse.

In this guide

  • Set up ABM.dev as a Segment destination
  • Configure identify-call enrichment
  • Create a source function for enrichment events
  • Route enriched data to your warehouse

Prerequisites

  • An ABM.dev account with an API key
  • A Segment workspace (free or paid)
  • A Segment source sending identify calls
1

Create a destination function

Segment Functions let you run custom code on every event. Create a destination function that calls ABM.dev whenever a user is identified.

  1. 1.Go to Connections → Functions → New Function → Destination
  2. 2.Paste the ABM.dev destination function code (shown below)
  3. 3.Add a setting called apiKey (type: string, required)
  4. 4.Save and deploy the function
Destination function
async function onIdentify(event, settings) {
  const res = await fetch("https://api.abm.dev/v1/enrichments", {
    method: "POST",
    headers: {
      "x-api-key": settings.apiKey,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      type: "person",
      input: {
        email: event.traits.email,
        firstName: event.traits.firstName,
        lastName: event.traits.lastName,
        company: event.traits.company?.name,
      },
    }),
  });

  if (!res.ok) {
    throw new RetryError(
      `ABM.dev API returned ${res.status}`
    );
  }
}
2

Connect to a source

Attach the destination function to any source that sends identify calls.

  1. 1.Go to your source and click Add Destination
  2. 2.Select the ABM.dev destination function you just created
  3. 3.Enter your ABM.dev API key in the settings
  4. 4.Enable the destination and send a test identify call

Retries and Error Handling

Use Segment's built-in retries and dead letter queue to handle API rate limits gracefully. The function uses RetryError to signal transient failures.
3

Create a source function (optional)

To route enriched data back into Segment (for example, into your data warehouse), create a source function that polls ABM.dev for completed enrichments and emits track events.

  1. 1.Go to Connections → Functions → New Function → Source
  2. 2.Write a function that calls the ABM.dev enrichments list endpoint with a status=completed filter
  3. 3.For each completed enrichment, emit a track("Enrichment Completed", ...) event with the enriched data as properties
  4. 4.Connect this source to your warehouse destination to store enriched data

Troubleshooting

Events not reaching ABM.dev

  • • Check the function logs in Segment → Functions → your function → Logs
  • • Verify the apiKey setting is correctly configured
  • • Ensure identify calls include an email trait

Enrichment data not appearing

  • • Check the source function polling interval (recommended: every 5 minutes)
  • • Verify the enrichment has completed by calling the status endpoint
  • • Ensure the source function is connected to a warehouse destination

Next Steps