How to set up Segment Source and Destination connections for lead attribution

Getting lead attribution right is surprisingly hard. Most teams either drown in scattered data or end up guessing where leads come from. If you’ve landed here, you probably want a straight-up guide to wiring up Segment so you can finally see which marketing stuff actually works—and which is a waste of money.

This guide is for marketers, growth folks, and anyone technical enough to poke around a dashboard. You don’t need to be a developer, but it helps if you’re not afraid of browser tabs. We’ll walk through connecting Sources and Destinations in Segment, with an eye on what matters for lead attribution. I’ll cut through the noise and flag what’s worth your time (and what isn’t).


Step 1: Know What You’re Actually Tracking

Before you touch Segment, get clear on your goal: you want to track which channels, campaigns, or touchpoints bring in leads. So, you need to connect the dots between:

  • Where traffic comes from (ads, social, email, etc.)
  • What users do on your site or app
  • When someone actually becomes a lead (fills out a form, signs up, etc.)
  • Where this data goes (your CRM, analytics, or warehouse)

Pro tip: If you don’t know what “becoming a lead” means for your team, stop here and figure that out first. Otherwise, you’ll just make a mess.


Step 2: Set Up Your Segment Workspace

If you don’t have a Segment account, sign up and create a workspace. Most teams use the “Connections” product, which is where Sources and Destinations live.

  • Go to Segment and create a workspace if you haven’t already.
  • Name things clearly. If your workspace is called “Q3 Attribution Test,” you’ll regret it in Q4.

Step 3: Add Your Source (Where Data Comes From)

A Source is anything that sends data into Segment. For lead attribution, you usually want:

  • Website (using Segment’s Analytics.js, or the newer Segment Web SDK)
  • Mobile app (if you have one)
  • Server-side (Node.js, Python, Ruby, etc.) — good for signup forms or backend events

How to Add a Source

  1. In Segment, go to Connections > Sources.
  2. Click Add Source.
  3. Pick the type of Source (e.g., “Website” for a web app).
  4. Give it a clear name (“Marketing Site - Production” beats “mysite123”).
  5. Segment will show you how to install the tracking snippet or SDK.

What actually matters:
If you’re just starting, the website is usually enough. Don’t overcomplicate it with every possible Source—you can add more later.


Step 4: Install the Segment Snippet (or SDK)

Here’s where things usually go sideways. You need to add Segment’s tracking code to your site or app.

  • For web: Copy the JavaScript snippet Segment gives you and paste it right before the closing </head> tag on your site.
  • For web frameworks (React, Next.js, etc.), use the official Segment package or a trusted community one.
  • For mobile apps: Follow Segment’s guide for your platform (iOS, Android).

Watch out for:
- Ad blockers and privacy browsers can block Segment. You won’t catch everything—don’t trust 100% of your data. - Don’t double-install: If you already have some analytics tool (like Google Analytics) and it’s set up through Segment, don’t add both scripts. You’ll get duplicate data.


Step 5: Track the Right Events

For lead attribution, you need to track at least these events:

  • Page views: To know where people landed (and what UTM parameters they brought)
  • Lead events: When someone fills out a lead form, signs up, or whatever counts as a lead for you

How to Track Events

  • Use analytics.page() to track page loads (usually automatic with Segment).
  • Use analytics.track('Lead Submitted', { ... }) when a form is filled or an account is created.

Best practice:
Include relevant properties with your track calls, like:

javascript analytics.track('Lead Submitted', { email: 'user@example.com', campaign: 'spring_launch', utm_source: 'google', utm_medium: 'cpc' });

Don’t go overboard:
You don’t need to track every click or scroll. Focus on actions tied to becoming a lead.


Step 6: Pass Through UTM Parameters (and Attribution Data)

If you don’t capture UTM parameters and original referrer data, you’ll never know where leads came from.

  • Make sure your Segment snippet or SDK is configured to grab UTM parameters from the URL and pass them along with events.
  • You might need a helper script to grab UTM params and stash them in localStorage or cookies (if the lead form is multi-step).

Pro tip:
There are open-source libraries (like utm-keeper or utm-cookie) that can help with this. Don’t reinvent the wheel if you don’t have to.


Step 7: Add a Destination (Where Data Goes)

Destinations are where Segment sends your data. For lead attribution, common Destinations include:

  • CRM (like Salesforce, HubSpot)
  • Analytics tools (Mixpanel, Amplitude, Google Analytics)
  • Data warehouse (Snowflake, BigQuery, Redshift)

How to Add a Destination

  1. In Segment, go to Connections > Destinations.
  2. Click Add Destination.
  3. Pick your tool (e.g., “HubSpot”), and connect your account.
  4. Map events carefully—make sure your “Lead Submitted” event in Segment matches what your Destination expects.

Watch out for:
- Each Destination has its own quirks. Some (like Salesforce) need custom mapping and API permissions. Don’t expect plug-and-play. - For warehouses, expect a delay. Data may not show up instantly.


Step 8: Test the Whole Flow

Don’t trust that just because you “set it up,” it works.

  • Fill out your own lead form with UTM parameters in the URL.
  • Check Segment’s Debugger to see if the right events (with right properties) fire.
  • Make sure the data lands in your Destination—are UTM fields showing up in Salesforce/HubSpot? If not, check your mapping.
  • Try again with an ad blocker to see what’s missing (spoiler: probably a lot).

Pro tip:
Use fake emails or test accounts to avoid polluting real data.


Step 9: Filter Out Junk and Internal Traffic

If you’re testing or your team is constantly hitting the site, you’ll skew your numbers.

  • Use Segment’s built-in filters to ignore traffic from your office IP or specific users (like your own email).
  • Set up logic in your Destination to exclude test data if Segment’s filtering isn’t enough.

Step 10: Actually Use the Data

Now that you’ve set up the plumbing, look at what’s coming through:

  • Does your CRM or analytics tool show where leads are coming from?
  • Are UTM parameters and other attribution data making it all the way through, or are they getting dropped?
  • Where are the gaps? (Spoiler: There will be gaps.)

Don’t get too hung up on having “perfect” attribution—it doesn’t exist. Your goal is to see trends, not to assign 100% credit.


What to Ignore (at Least for Now)

  • Advanced identity resolution: You don’t need to stitch anonymous and known users on day one.
  • Every possible Source/Destination: Start with what you actually use.
  • Endless custom events: More events = more noise. Stick to what helps you answer real questions.

Real Talk: What Works and What Doesn’t

What works: - Keeping your tracking setup dead simple. - Testing the flow end-to-end, not just turning things “on.” - Making sure your lead events include the actual attribution data (UTMs, referrer, etc.)

What doesn’t: - Hoping Segment will “magically” solve attribution. It’s just a pipe, not an analytics brain. - Ignoring Destination mapping—data gets lost in translation more often than you’d think. - Forgetting to exclude your team’s test traffic.


Wrapping Up: Keep It Simple, Iterate Fast

You’ll be tempted to set up every integration under the sun. Don’t. Start with clear, simple tracking for your main lead source, one Destination, and real events that matter. Test each step, fix what’s broken, and only add complexity if you actually need it. Attribution is about getting answers, not building a Rube Goldberg machine.

When in doubt, go back to basics: Where did the lead come from, and did that data make it into your CRM or analytics tool? If you’ve got that, you’re already ahead of most teams. Happy tracking.