Migrating from Segment to RudderStack
Step-by-step guide on migrating from Segment to RudderStack.
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, you can contact us.
Updating the SDK implementation
Depending on the platform, follow these steps to move your existing SDK implementation to RudderStack:
Android iOS JavaScript .NET React Native
Change the dependencies in your
app/build.gradle
file add the following:Under dependencies, add the following:
Update your SDK initialization to the following snippet. Replace
WRITE_KEY
andDATA_PLANE_URL
with your source write key and data plane URL obtained above.Update the use of the classes according to the following table:
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.
Change the dependencies in the
Podfile
of your project:Update your SDK initialization to the following. Replace
WRITE_KEY
andDATA_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
toRudder.h
wherever necessaryUpdate 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.
Add the SDK to your web application:
For the minified version of the above script, refer to the RudderStack JavaScript SDK guide.
If you are using an older version of the JavaScript SDK (v1), refer to the Version Migration Guide to migrate to v1.1.
Update the object. RudderStack uses
rudderanalytics
as the global object library as compared to Segment'sanalytics
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 NuGetThen, initialize the RudderStack client by running the following code snippet. Replace
WRITE_KEY
andDATA_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:
Then, import the React Native SDK.
Next, change the SDK initialization as shown in the following snippet. Replace
WRITE_KEY
andDATA_PLANE_URL
with your source write key and data plane URL obtained above.Update the references to the
analytics
keyword in your application code withrudderClient
.You can use the rest of your code without any changes as the RudderStack API is fully compatible with Segment.
Backfilling Segment anonymous IDsWhen 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 SegmentanonymousId
automaticallyYou can automatically capture the Segment
anonymousId
and set it as RudderstackanonymousId
using the JavaScript SDK'sanonymousIdOptions
object. When enabled, it reads the SegmentanonymousId
from your local storage (localStorage
) or the Segment cookie and sets it accordingly.For more information on how to enable the
anonymousIdOptions
object, refer to the Capturing anonymousId automatically section.Contact usIf you're stuck somewhere in the migration process, you can contact us or start a conversation in our Slack community.
Last updated