Phase 1: Basic SDK, Event, and Property migration
6 minute read
RudderStack provides a wide range of SDKs for different platforms, including JavaScript, iOS, Android, and server-side languages like Node.js, Python, and Ruby.
This guide covers the process of updating your SDK, events, and properties implementation for web, mobile, and server while migrating from Segment to RudderStack.
JavaScript SDK
- Install the RudderStack JavaScript SDK by including the JavaScript SDK installation snippet in the
<head>section of your website.
Make sure to replace the write keyThe write key (or source write key) is a unique identifier for your source. RudderStack uses this key to send events from a source to the specified destination. and data plane URLThe data plane URL is the location where events are routed and sent to the RudderStack backend for processing. You can find this URL at the top of the Connections page in your RudderStack dashboard. with their actual values from the RudderStack dashboard.
- Update your
page,track, andidentifycalls to use the RudderStack SDK. RudderStack and Segment calls are nearly identical. Here are a few examples:
// Segment
analytics.identify("user_id", {
name: "John Doe",
email: "john@example.com",
plan: "Premium"
});
// RudderStack
rudderanalytics.identify("user_id", {
name: "John Doe",
email: "john@example.com",
plan: "Premium"
});// Segment
analytics.page();
// RudderStack
rudderanalytics.page();// Segment
analytics.track("Order Completed", {
order_id: "12345",
revenue: 99.95,
shipping_method: "FedEx"
});
// RudderStack
rudderanalytics.track("Order Completed", {
order_id: "12345",
revenue: 99.95,
shipping_method: "FedEx"
});- After implementing your calls, verify that the data flows correctly by checking the Live Events tab in your RudderStack dashboard. You should see events appearing in real time as users interact with your website.
iOS (Obj-C)/Android (Java) SDK
The native iOS (Obj-C) or Android (Java) SDK implementations can be migrated similarly and the calls will be very similar to Segment as well.
Your write keyThe write key (or source write key) is a unique identifier for your source. RudderStack uses this key to send events from a source to the specified destination. changes per source but your data plane URLThe data plane URL is the location where events are routed and sent to the RudderStack backend for processing. You can find this URL at the top of the Connections page in your RudderStack dashboard. stays the same.
Example for iOS
- Install the RudderStack iOS (Obj-C) SDK as follows:
RSConfigBuilder *builder = [[RSConfigBuilder alloc] init];
[builder withDataPlaneUrl:"DATA_PLANE_URL"];
[RSClient getInstance:"WRITE_KEY" config:[builder build]];RSConfigBuilder *builder = [[RSConfigBuilder alloc] init];
[builder withDataPlaneUrl:"DATA_PLANE_URL"];
[RSClient getInstance:"WRITE_KEY" config:[builder build]];Replace the write keyThe write key (or source write key) is a unique identifier for your source. RudderStack uses this key to send events from a source to the specified destination. and data plane URLThe data plane URL is the location where events are routed and sent to the RudderStack backend for processing. You can find this URL at the top of the Connections page in your RudderStack dashboard. with their actual values from the RudderStack dashboard.
- Implement
identifyandtrackcalls in your app as below:
RSClient.sharedInstance()?.identify("user_id", traits: [
"key_1": "value_1",
"key_2": "value_2",
"email": "alex@example.com"
])RSClient.sharedInstance()?.track("user_id", properties: [
"key_1": "value_1",
"key_2": "value_2"
])- Verify the data flow by checking the Live Events tab in your RudderStack dashboard.
See the RudderStack Android (Java) SDK and iOS (Obj-C) SDK documentation for detailed implementation and examples.
Server-side SDKs
RudderStack supports eight different server-side SDKs that can be implemented similarly to Segment.
Example for Node.js
- Install the RudderStack Node.js SDK using npm:
npm install @rudderstack/rudder-sdk-node- Import and initialize the SDK in your Node.js app:
const RudderAnalytics = require('@rudderstack/rudder-sdk-node');
const client = new RudderAnalytics(WRITE_KEY, {
dataPlaneUrl: YOUR_DATA_PLANE_URL,
// More initialization options
});Replace the write keyThe write key (or source write key) is a unique identifier for your source. RudderStack uses this key to send events from a source to the specified destination. and data plane URLThe data plane URL is the location where events are routed and sent to the RudderStack backend for processing. You can find this URL at the top of the Connections page in your RudderStack dashboard. with their actual values from the RudderStack dashboard.
- Implement
identifyandtrackcalls in your server-side code:
client.identify({
userId: "1hKOmRA4GRlm",
traits: {
name: "Alex Keener",
email: "alex@example.com",
plan: "Free",
friends: 21,
},
})client.track({
userId: "1hKOmRA4GRlm",
event: "Item Viewed",
properties: {
revenue: 19.95,
shippingMethod: "Premium",
},
})- Verify the data flow by checking the Live Events tab in your RudderStack dashboard.
Historical data imports
If you have a significant amount of historical data in your Segment warehouse and you are moving warehouses, you should migrate your historical Segment data into your new warehouse (Snowflake, BigQuery, Databricks, etc.) using your preferred ETL tool.
Once data is in your new data warehouse, you can combine SQL tables for a unified historical view of your customer data.
If you are not changing data warehouses, you don’t need to set up pipelines.
Migrate user traits and event properties
When migrating from Segment to RudderStack, follow these steps to ensure that all your custom user traits and event properties are properly mapped and migrated:
Identify the key user traits and event properties that you want to migrate from Segment to RudderStack. The easiest way to do this is to set up Segment as a source in a RudderStack Tracking Plan.
Create new events in the RudderStack Data Catalog:

- Update your RudderStack SDK implementation to use the mapped trait and property names, ensuring your data is correctly structured and labeled in RudderStack.
- If you have any downstream destinations or data, consumers that rely on the Segment trait and property names, update their configurations to use the new RudderStack names.
- Verify that your user traits and event properties are correctly captured and forwarded by RudderStack by inspecting your live events stream and destination data.
By carefully mapping and migrating your user traits and event properties, you can maintain data consistency and ensure that your downstream systems continue to function as expected.
Handle custom events and mappings
If your Segment implementation includes custom events or mappings, you can set up Segment as a RudderStack source to import your existing mappings into a RudderStack tracking plan and manage them in the RudderStack data catalog. Otherwise, you must recreate your schema in RudderStack to ensure a seamless migration by following these steps:
- Identify any custom events or mappings in your Segment implementation like custom page or screen events, e-commerce events, or user attribute mappings.
- For each custom event, create an equivalent event in RudderStack using the
trackmethod and the appropriate event name and properties. For example:
// Segment
analytics.track("Custom Event Name", {
property1: "value1",
property2: "value2"
});
// RudderStack
rudderanalytics.track("Custom Event Name", {
property1: "value1",
property2: "value2"
});- If you have any custom mappings or transformations in Segment like user attribute synchronization or event property renaming, implement them in RudderStack using the JavaScript SDK’s
identifyandtrackmethods or by leveraging RudderStack’s server-side transformations. - Test your custom events and mappings thoroughly to ensure that they are being correctly captured and processed by RudderStack.
- Update any downstream systems or integrations that rely on the custom events or mappings to use the new RudderStack event names and property structures.
By handling custom events and mappings during the migration process, you can ensure that your data remains consistent and actionable across your entire stack.
Next steps
Phase 2: Advanced migration techniques