Latest 1.3.1
Homepage https://github.com/AppsFlyerSDK/segment-appsflyer-ios
License MIT
Platforms ios 7.0, tvos 9.0, requires ARC
Dependencies Analytics
Authors

segment-appsflyer-ios

AppsFlyer integration for Segment.

This is a Segment wrapper for AppsFlyer SDK framework.


In order for us to provide optimal support, we would kindly ask you to submit any issues to [email protected]

When submitting an issue please specify your AppsFlyer sign-up (account) email , your app ID , production steps, logs, code snippets and any additional relevant information.


Table of content

Installation

To install the segment-appsflyer-ios integration, simply add this line to your CocoaPods Podfile:

pod 'segment-appsflyer-ios'

Usage

First of all, you must provide values for AppsFlyer Dev Key, Apple App ID (iTunes) and client secret in Segment’s dashboard for AppsFlyer integration

Usage – Objective-C

Open AppDelegate.h and add:

In AppDelegate.mdidFinishLaunchingWithOptions:

SEGAnalyticsConfiguration *config = [SEGAnalyticsConfiguration configurationWithWriteKey:@"SEGMENT_KEY"];

    [config use:[SEGAppsFlyerIntegrationFactory instance]];

    config.enableAdvertisingTracking = YES;       //OPTIONAL
    config.trackApplicationLifecycleEvents = YES; //OPTIONAL
    config.trackDeepLinks = YES;                  //OPTIONAL
    config.trackPushNotifications = YES;          //OPTIONAL
    config.trackAttributionData = YES;            //OPTIONAL   
    [SEGAnalytics debug:YES];                     //OPTIONAL
    [SEGAnalytics setupWithConfiguration:config];

Usage – Swift

Open/Create <Your-App-name>-Bridging-Header.h and add:

#import "SEGAppsFlyerIntegrationFactory.h"

Open AppDelegate.swiftdidFinishLaunchingWithOptions and add:


import Analytics

//...

let config:Analytics.SEGAnalyticsConfiguration = SEGAnalyticsConfiguration(writeKey: "SEGMENT_KEY")

        config.use(SEGAppsFlyerIntegrationFactory())
        config.enableAdvertisingTracking = true       //OPTIONAL
        config.trackApplicationLifecycleEvents = true //OPTIONAL
        config.trackDeepLinks = true                  //OPTIONAL
        config.trackPushNotifications = true          //OPTIONAL
        config.trackAttributionData = true            //OPTIONAL

        Analytics.SEGAnalytics.debug(true)
        Analytics.SEGAnalytics.setup(with: config)

AppsFlyer integration responds to identify call. To read more about it, visit Segment identify method documentation.
In identify call traits dictionary setCustomerUserID and currencyCode

Install Attributed event

If you are working with networks that don’t allow passing user level data to 3rd parties, you will need to apply code to filter out these networks before calling

// [self.analytics track:@"Install Attributed" properties:[properties copy]];

Additional AppsFlyer SDK setup

@import AppsFlyerLib;

...
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(integrationDidStart:) name:SEGAnalyticsIntegrationDidStart object:nil];
    ...
}

...

- (void)integrationDidStart:(nonnull NSNotification *)notification {
    NSString *integration = notification.object;
    if ([integration isEqualToString:@"AppsFlyer"]) {
        /// Additional AppsFlyer SDK setup goes below
        /// All setup is optional
        /// To set Apple App ID and AppsFlyer Dev Key use Segment dashboard
        /// ...
        /// Enable ESP support for specific URLs
        [[AppsFlyerTracker sharedTracker] setResolveDeepLinkURLs:@[@"afsdktests.com"]];
        /// Disable printing SDK messages to the console log
        [[AppsFlyerTracker sharedTracker] setIsDebug:NO];
        /// `OneLink ID` from OneLink configuration
        [[AppsFlyerTracker sharedTracker] setAppInviteOneLink:@"one_link_id"];
    }
}

Examples

This project has 4 examples for objective-C and Swift (with troubleshooting). To give it a try , clone this repo and from each example first run pod install to install project dependancies.

Latest podspec

{
    "name": "segment-appsflyer-ios",
    "version": "1.3.1",
    "summary": "AppsFlyer Integration for Segment's analytics-ios library.",
    "description": "AppsFlyer is the market leader in mobile advertising attribution & analytics, helping marketers to pinpoint their targeting, optimize their ad spend and boost their ROI.",
    "homepage": "https://github.com/AppsFlyerSDK/segment-appsflyer-ios",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Appsflyer": "[email protected]"
    },
    "source": {
        "git": "https://github.com/AppsFlyerSDK/segment-appsflyer-ios.git",
        "tag": "1.3.1"
    },
    "platforms": {
        "ios": "7.0",
        "tvos": "9.0"
    },
    "requires_arc": true,
    "static_framework": true,
    "dependencies": {
        "Analytics": [
            "~> 3.5"
        ]
    },
    "source_files": "segment-appsflyer-ios/Classes/**/*",
    "ios": {
        "dependencies": {
            "AppsFlyerFramework": [
                "4.10.0"
            ]
        }
    },
    "tvos": {
        "dependencies": {
            "AppsFlyerFramework": [
                "4.10.0"
            ]
        }
    }
}

Pin It on Pinterest

Share This