Segment Integration
Learn to integrate Featurebase with Segment and the key features.
Written By Markus Palm
Last updated 1 day ago

Overview
The Featurebase ↔ Segment integration enables you to easily track all events (like new posts, comments, and votes) that your users make on your Public Portal.
Key features:
Track different events, page views, and user actions on your Featurebase Portal
Sync your users’ data from Segment to Featurebase for better feedback prioritization, etc.
Example: If you already have your user data in Segment, you can sync it with their feedback in Featurebase to see their info (e.g. plan, company size, etc.) next to their posts.
Setting up the Segment integration
Install the Segment integration
Start in Segment by going to the connections tab, and click Add Source

Select Javascript and click next on the bottom right corner
Enter your website name (e.g. “yourcompany feedback portal”)
Add the website URL, which is your Featurebase Portal’s URL (e.g. https://yourcompany.featurebase.app/)

Click Create Source
Copy the text (Write key) in the analytics.load() function as seen below 👇

Go to Featurebase Settings → Integrations
Click Configure on Segment, paste your Segment write key under Send events to Segment, and click Save
All done! 🎉 You can now see all the events made on your feedback portal appear under the Debugger in Segment.
Sync users from Segment to Featurebase
A Segment destination function sends each identify call to Featurebase with your Segment key. Featurebase saves the person with their name, email, custom fields and company. This needs the Growth plan or higher.
In Featurebase Settings → Integrations, click Configure on Segment, then Create key under Sync users from Segment. Copy the key: it is shown only once.
In Segment, go to Connections → Catalog, open the Functions tab and click New Function
Select Destination and click Next: Build Function
Replace all of the code with this, and change
YOURORGto your Featurebase subdomain:// Sync Segment identify calls to Featurebase. // Replace YOURORG with your Featurebase subdomain (YOURORG.featurebase.app). const ENDPOINT = 'https://YOURORG.featurebase.app/api/v1/webhook/segment/identify'; // Map your Segment traits to Featurebase. Change the trait names to match yours. function toFeaturebase(event) { const traits = event.traits || {}; const firstName = traits.firstName || traits.first_name; const lastName = traits.lastName || traits.last_name; const avatar = traits.avatar || traits.profilePicture; const company = traits.company; return { userId: event.userId, email: traits.email, name: traits.name || [firstName, lastName].filter(Boolean).join(' ') || undefined, profilePicture: /^https?:\/\//.test(avatar || '') ? avatar : undefined, createdAt: traits.createdAt || traits.created_at, // Each key must match a user attribute in Featurebase (Settings → Data → Users). customFields: { plan: traits.plan }, companies: company && company.id && company.name ? [{ id: String(company.id), name: company.name }] : undefined, }; } async function onIdentify(event, settings) { const key = (settings.featurebaseKey || '').trim(); if (!key) throw new ValidationError('Add your Featurebase key in the destination settings.'); if (!event.userId) throw new EventNotSupported('Featurebase needs a userId.'); let response; try { response = await fetch(ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` }, body: JSON.stringify({ userId: event.userId, featurebaseIdentify: toFeaturebase(event) }), }); } catch (error) { throw new RetryError(error.message); } if (response.status >= 500 || response.status === 429) throw new RetryError(`Featurebase answered ${response.status}`); if (!response.ok) throw new ValidationError(`Featurebase answered ${response.status}: ${await response.text()}`); }In the Settings tab, click Add Setting: label
featurebaseKey, type String, with Required and Secret onClick Configure, enter a name (e.g. Featurebase) and click Create Function
Click Connect Destination and select a server-side source, such as your backend
In the destination settings, paste your Featurebase key into
featurebaseKey, click Save and turn the destination on
Use a server-side source. Visitors can change the data a website source sends.
A custom field is saved when a user attribute with the same name exists in Settings → Data → Users.
If your workspace uses identity verification, Segment updates people who already exist in Featurebase. New people are added when they sign in.
This syncs users. To send product events, use the Events API.
And that's it! 🎉 If you have any ideas about how we can improve the Segment integration, please post on our feedback board.
Was this helpful?
More in Automation
Featurebase MCP serverCursor integrationStill need help? Ask the team