Asset 20 8 2
Does AI recommend your business? Run the free check →

Join 15,000 business owners, marketers and entrepreneurs. The Sunday newsletter you'll be annoyed only arrives once a week.

Article

How to Create a Source in Segment and Find Its Write Key

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

TypeCoversKey
Event streamsWebsites, server libraries and mobile SDKs sending eventsA write key per source
Cloud app sourcesData from a connected cloud serviceNo write key; uses a token or key from your account with that service
Reverse ETLThe third source type Segment listsNot 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.

Work with me

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.

Published and maintained by the Lilach Bullock team, covering marketing, AI and business growth.
Your buyers are asking AI who to use. Does it say you?

See for free whether ChatGPT, Claude, Perplexity, Gemini and Google name you, and get the plan to become the answer.

Check my AI visibility →
Sundays only

Get the Sunday newsletter.

One email a week. AI experiments, marketing tactics, and the workflows Lilach is building right now in her own business.

Subscribe free

Let’s get your marketing running on AI.

Book a free 30-minute call

We figure out what you need, where AI fits in, and what working together would look like.

Book the call →

Or take the 30-second calculator

You’ll see the hours and the money quietly leaking out of your week, and the three workflows worth building first.

Take the calculator →

Or grab the free AI resource library

Prompt packs, templates, checklists, and swipe files. The exact tools I build for paying clients. Yours, free.

Get the library →
Keep reading

More from the blog.