SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

How to Enrich Segment Tracking Payloads with Internal Data

Question

How can I enrich my Segment tracking payloads with additional properties from an internal database before they are sent to downstream destinations? Is using an Insert Function the best way to handle this, or are there better alternative methods like Reverse ETL or Linked Events for injecting this data at scale?

 

Product

Twilio Segment

 

Environment

Segment Console

 

Answer

To enrich event payloads with external database mappings, there are three main approaches depending on your specific use case and scale requirements:

 

1. Destination Insert Functions You can use a Destination Insert Function to enrich your payloads by making custom JavaScript calls, including fetch() requests, to your internal API or database. Use this method only if your mapping data cannot be stored in a warehouse and your internal API is highly performant. Keep the following performance impacts in mind:
  • Insert Functions have a strict 5-second execution timeout. If your API is slow or under heavy load, the function may time out, causing retries and potential pipeline delays.
  • Segment bills for Functions based on total execution time. Frequent or slow external API calls can significantly increase your total execution time and costs.
  • While you can use global variables to cache small amounts of information between invocations, this cache is not persistent or distributed and is not suitable for large or critical mapping tables.

 

2. Linked Events (Recommended for Real-Time Enrichment) If your mapping table resides in a supported data warehouse (Snowflake, BigQuery, Redshift, or Databricks), Linked Events is the most robust solution.

  • Linked Events can natively join your mapping data to event payloads in real time.
  • This approach eliminates the need for external API calls, reduces latency, and scales efficiently.

 

3. Reverse ETL (For User Trait Syncing) If real-time enrichment is not required, Reverse ETL is a highly effective alternative.

  • Reverse ETL moves data in batches from your warehouse to third-party tools, not in real time.
  • You can use Reverse ETL to send Identify calls back into Segment, which updates user profiles with the mapped traits. Downstream tools that maintain user profiles will then associate these traits with future events.

 

Have more questions? Submit a request
Powered by Zendesk