You can do a lot of amazing things with Segment's API. Segment's API enables you to collect and connect customer data quickly and easily. With it, you can power your analytics, marketing, and data warehousing requirements, and improve your customer experience and performance.
The Segment API provides you with full control over your customer data, including file storage, ETL, data modeling, data enrichment and transformations, and data queries. With it, you can build powerful solutions that help you uncover useful customer insights in real-time. Here are a few examples of what you can do using the Segment API:
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,
})
},
})
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.