Getting started
Welcome to Segments. This short guide walks you through registering an account, creating your first source, and sending your first event from a Go service.
1. Create your account
Head over to the sign-up page and create a free account. You'll get 14 days of full access — no credit card required.
2. Create a source
Once logged in, open the cabinet and go to Sources → New source. Pick a name (e.g. backend-api) and choose the Server (Go) type. Segments will generate a unique write key — copy it, you'll need it in the next step.
3. Install the Go SDK
Segments is wire-compatible with segmentio/analytics-go. Install it in your service:
go get gopkg.in/segmentio/analytics-go.v34. Send your first event
Initialize a client with your write key and emit a Track call:
package main
import (
"log"
analytics "gopkg.in/segmentio/analytics-go.v3"
)
func main() {
client, _ := analytics.NewWithConfig("YOUR_WRITE_KEY", analytics.Config{
Endpoint: "https://api.segments.example.com",
})
defer client.Close()
if err := client.Enqueue(analytics.Track{
UserId: "user-42",
Event: "Signed Up",
Properties: analytics.NewProperties().
Set("plan", "starter").
Set("source", "backend-api"),
}); err != nil {
log.Fatal(err)
}
}5. Verify in the cabinet
Open Sources → backend-api → Debugger in the cabinet. Your Signed Up event should appear within a few seconds.
Tip: events are buffered in-memory and flushed in batches. Always call client.Close() on shutdown so the last batch is flushed. What's next?
- Connect a destination (Webhook, Postgres, Kafka) to fan-out events.
- Build your first audience in Segments → New segment.
- Read our engineering blog for deep dives.
