To create a source in Segment, open your workspace's Sources catalog, select your source (for example JavaScript), click Add Source and name it, optionally adding an environment label such as dev. Then find the write key under Connections > Sources > Settings > API Keys. Create separate sources for development and production.
Every piece of data that reaches Segment comes in through a source, so this is the first thing you set up. A source is a website, server library, mobile SDK or cloud application that can send data into Segment.
Three kinds of source
| Type | Covers | Key |
|---|---|---|
| Event streams | Websites, server libraries and mobile SDKs sending events | A write key per source |
| Cloud app sources | Data from a connected cloud service | No write key; uses a token or key from your account with that service |
| Reverse ETL | The third source type Segment lists | Not covered in the quickstart |
If a tool isn't in the source catalog, you can use the HTTP API source or Functions to collect its data.
One source per site, app and environment
Segment recommends creating a source for each website or app you want to track, and one per unique source of data. It also recommends separate sources for production, development and staging, labelled with environment labels like dev. That keeps test traffic out of your real numbers, and it's a lesson most teams learn the first time someone runs a load of test events from their laptop.
For test sources, Segment suggests putting demo, test or quickstart in the name, so you can find and delete them later.
Creating the source
1. Open the catalog
Go to your Segment workspace and open the Sources catalog.
2. Choose the source type
Select the source that matches your site or app, such as JavaScript, PHP or iOS, and click Add Source.
3. Name it
Enter a name. Include the site or app and the environment, and add demo, test or quickstart for anything temporary.
4. Label it
Optionally add an environment label such as dev, and the website URL.
5. Copy the write key
Go to Connections > Sources, select the source, open the Settings tab, then API Keys, and copy the write key. Each source has its own write key, used to send data to that source.
6. Send a test event
Install the library, send a test event and check the Source Overview.
A naming pattern that stays tidy
Names are the only thing that tells sources apart in a busy workspace, so it's worth agreeing a pattern before you've got ten of them. Something like the product, the platform and the environment works well: Shop website production, Shop website dev, Shop iOS production. Test sources get test or quickstart in the name, as Segment suggests, so anyone tidying up later knows they're safe to delete. You'll thank yourself when you're picking a write key under pressure.
Want AI doing the heavy lifting in your marketing?
I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.
Reading the Source Overview
For an event stream source, the Source Overview shows a pipeline: events received, failed on ingest, filtered at source, and eligible events. If your test event shows as received but not eligible, something in between is stopping it, and the pipeline tells you which stage to look at.
The write key can change under you
Twilio Segment Docs flag the detail that wastes the most debugging time. Any time you change a library's settings in the Segment App, the write key regenerates. If data stops arriving after someone tweaks a setting, check you're using the current key before you dig into your code.
Getting more from the data
A source is only the start: the data's useful once it reaches the tools that act on it. For an overview of what to do with it, my guide to using product analytics covers the next step, and my roundup of customer database software looks at where customer data ends up.
My advice for your first Segment sources
Create two sources from day one, one for development and one for production, and label them clearly. Name test sources with test or demo so they're easy to clear out. Copy the write key into your app's settings rather than hardcoding it, and recheck it whenever someone changes the library's settings. Then send one event and watch it travel through the Source Overview before you add any more.
Want your tool on this list? Featured spots and reviews here are paid partnerships. Here's how to partner with me.
Frequently asked questions
What is a source in Segment?
A website, server library, mobile SDK or cloud app that sends data into Segment.
Where do I find my write key?
Connections > Sources, pick the source, Settings, API Keys.
Do cloud sources have write keys?
No. They use a token or key from the connected service.
Should I use one source for dev and prod?
No. Segment recommends separate sources with environment labels.
What if my tool isn't listed?
Use the HTTP API source or Functions.