The Segment API enables you to collect, manage, and route your customer analytics data to various tools for marketing, analytics, and data warehousing. By harnessing the Segment API on Pipedream, you can automate the ingestion and syncing of user events and properties to multiple destinations, allowing you to create seamless data pipelines without manual intervention. Pipedream's serverless platform empowers you to build custom workflows that react to events in real-time, enrich data, or trigger actions across your tech stack.
import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
segment: {
type: "app",
app: "segment",
}
},
async run({steps, $}) {
const data = {
"event": `PipedreamTestOrder`,
"anonymousId": `019mr8mf4r`,
}
return await axios($, {
method: "post",
url: `https://api.segment.io/v1/track`,
headers: {
"Content-Type": `application/json`,
},
auth: {
username: `${this.segment.$auth.write_key}`,
password: ``,
},
data,
})
},
})
User Signup Attribution: Track the source of new user signups by capturing signup events via Segment and enriching them with the original referral source. Then, store this information in a Google Sheet for further analysis or use in marketing campaigns.
Personalized Email Campaigns: When a user performs a specific action tracked by Segment, like completing a purchase, trigger an automated email via SendGrid with personalized recommendations or a thank-you note based on the user’s purchase history.
Real-time Slack Alerts: Set up real-time notifications to a Slack channel when high-value customers perform key actions in your app, like upgrading their subscription. Use this workflow to alert sales or support teams to engage with the customer proactively.
Send events to a webhook. Requires a Team or Business account.
Identify lets you tie a user to their actions and record traits about them. It includes a unique User ID and any optional traits you know about them (note requires userId or anonymousId). See the docs here
Segment uses API keys for authentication. When you connect your Segment account, Pipedream securely stores the keys so you can easily authenticate to Segment APIs in both code and no-code steps.
Segment's APIs are accessed programmatically using access tokens, as well as write keys.
Create access tokens via the Access Management page in your account: https://app.segment.com/{your-workspace-name}/settings/access-management
. See "Get a Token" for more details. Please note, that you must be on a Team or Business plan to create an access token.
You will also need to find your write key, which is a unique identifier for your Source. To find a write key, you first need to create a non-Cloud Source such as a website, server, or mobile source. (Cloud-sources do not have write keys, as they use a token or key from your account with that service.) Then, in the Source, go to “Settings’, and then go to “API Keys”. See "Locating Your Write Key" for more details.