This document explains the step-by-step process of migrating from Segment to RudderStack. It covers the necessary steps for replacing your instrumentation code and start using the RudderStack SDKs to track your events with minimal code changes.
Migrating the workspace
After creating a RudderStack account, you will see the following dashboard containing your data plane URL:
Similar to Segment, you will need to set up your source-destination connections in the dashboard and facilitate the event data flow.
Keep your source write key and the data plane URL handy.
If you need more support or want us to manage your hosting, contact us.
Updating the SDK implementation
Depending on the platform, follow these steps to move your existing SDK implementation to RudderStack:
Change the dependencies in your app/build.gradle file add the following:
Update your SDK initialization to the following snippet. Replace WRITE_KEY and DATA_PLANE_URL with your source write key and data plane URL obtained above.
The instance of the RudderClient is available at [RudderClient sharedInstance] whereas the Segment Instance is available at [Analytics sharedAnalytics]
Update the imports from Analytics.h to Rudder.h wherever necessary
Update the use of the classes according to the table below:
Segment
RudderStack
Analytics
RudderClient
Traits
RudderTraits
Property
RudderProperty
You can use the rest of your code without any changes as the RudderStack API is fully compatible with Segment.
For the minified version of the above script, see the JavaScript SDK documentation.
If you are using an older version of the JavaScript SDK (v1), see the migration guide to migrate to v1.1.
Update the object. RudderStack uses rudderanalytics as the global object library as compared to Segment’s analytics object.
You can use the rest of your code without any changes as the RudderStack API is fully compatible with Segment.
Change your .NET project’s Dependencies to include the RudderAnalytics package via NuGet
initialize the RudderStack client by running the following code snippet. Replace WRITE_KEY and DATA_PLANE_URL with your source write key and data plane URL obtained above.
You can use the rest of your code without any changes as the RudderStack API is fully compatible with Segment.
Install the RudderStack React Native SDK by running the following command:
// npm
npm install @rudderstack/rudder-sdk-react-native --save
// yarn
yarn add @rudderstack/rudder-sdk-react-native
// navigate to iOS folder and run pod install
pod install
Change the SDK initialization as shown in the following snippet. Replace WRITE_KEY and DATA_PLANE_URL with your source write key and data plane URL obtained above.
Update the references to the analytics keyword in your application code with rudderClient.
You can use the rest of your code without any changes as the RudderStack API is fully compatible with Segment.
Backfilling Segment anonymous IDs
When migrating from Segment or a similar analytics tool, you might already have some anonymous traffic that has not yet been identified. When Segment and RudderStack track events for non-identified users, both assign a random UUID as an anonymousId. This ID is used to track an unknown user until they are identified. It also allows RudderStack to track user behavior, journeys, and first-touch attribution before and after the users are identified.
Capturing Segment anonymousId automatically
You can automatically capture the Segment anonymousId and set it as RudderStack anonymousId using the JavaScript SDK’s anonymousIdOptions object. When enabled, it reads the Segment anonymousId from your local storage (localStorage) or the Segment cookie and sets it accordingly.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.