App Setup: How to integrate Segment/Leanplum [iOS]


To set up the segment-integrated Leanplum SDK, see the setup instructions in Segment's documentation, then follow the steps below.

CocoaPods is the dependency manager for Objective-C projects.
NOTE: If you already have CocoaPods installed and have a podfile, please skip to step 3.

  1. Install CocoaPods by running the following command:

    $ sudo gem install cocoapods

    For issues with installing CocoaPods, please refer here.

  2. Add a Podfile. In terminal, navigate to your app's directory. Add a podfile to your app by running the following command:

    $ pod init

  3. Open your podfile by running the following command:

    $ open -a Xcode Podfile

  4. Insert the following line of code into your Podfile:

    pod 'LeanplumSegment', '~> 1.0.1'

    Your podfile should look like the following: 
  5. Now, install the SDK by running the following command:

    $ pod install

  6. Import the LeanplumSegment integration:

    #import <LeanplumSegment/SEGLeanplumIntegrationFactory.h>

    Add the following lines into your AppDelegate:
    NSString *const SEGMENT_WRITE_KEY = @" ... ";
    SEGAnalyticsConfiguration *config =
        [SEGAnalyticsConfiguration configurationWithWriteKey:SEGMENT_WRITE_KEY];
    [config use:[SEGLeanplumIntegrationFactory instance]];
    [SEGAnalytics setupWithConfiguration:config];
    Make sure to place your Segment Write key within the code. This block of code also calls for Leanplum start. 

  7. Make some track calls: 

    To use the integration, use the following line of code to properly track events within the App: 
    [[SEGAnalytics sharedAnalytics] track:@" ... "];
  8. Push Notifications

    In addition to that you can also use the advanced features of Leanplum. Once the Leanplum SDK is successfully registered, Segment posts a NSNotification, hence register to it: 
    - (BOOL)application:(UIApplication *)application
        didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      [[NSNotificationCenter defaultCenter]
    - (void)segmentIntegrationDidStart {
      [Leanplum onVariablesChanged:^{


If you would like more information about the integration, as well as an example project, please refer Leanplum-Segment-iOS Github. As always, feel free to reach out to with any other questions.  

Was this article helpful?
Have more questions? Submit a request