본문으로 건너뛰기

Quick start guide for iOS

This page describes essential information to integrate the NAVER App Tracking SDK into iOS apps. For more information, see How to integrate the SDK.

Prerequisites

Before you begin, check the following requirements:

  • The SDK supports iOS 10.0 or later.
  • To integrate the SDK, you need a “site ID.” For more information, see Get a site ID.

Install the SDK

You can install the SDK using CocoaPods.

pod 'NTrackerSDKExt'

Configure and initialize the SDK

Follow the instructions below to configure and initialize the SDK.

  • Call the configure API in application(_:didFinishLaunchingWithOptions:) to initialize the SDK.
  • Set whether to display debug logs in the XCode console using the enableDebugLog API.
  • Set the server environment using phase.
  • When you publish your app on the app store, the phase must be set to Release, and whether to display logs to false.
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

NTrackerExt.enableDebugLog(true)
NTrackerExt.configure(serviceID: serviceID, phase: .debug)

return true
}
}

For more information, see Configure and initialize the SDK in How to integrate the SDK.

Set funnels

You can collect funnel data for app conversions that occur through a Universal Link or Custom URL Scheme for more accurate conversion tracking. Follow the instructions below:

  • Collect funnel data using the setInflow API.
  • To measure conversion tracking through NAVER Ads, use the setInflow API to collect URL information. If you use a deep link provided by a third party’s tracker, you need to pass the URL information as it is using the setInflow API before it is processed by the tracker.

Depending on whether you use AppDelegate or SceneDelegate, the implementation code is different. For more information, see Set funnels in How to integrate the SDK.

AppDelegate

With AppDelegate, the code should be as follows:

class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// Universal Link URL
if userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let urlUniversalLink = userActivity.webpageURL {
NTrackerExt.setInflow(url: urlUniversalLink)
}

// Your Codes.
}

func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// Custom URL Scheme
NTrackerExt.setInflow(url: url)

// Your Codes.
}

}

SceneDelegate

With SceneDelegate, the implementation code should be as follows:

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
// Universal Link URL. App is not running
if let urlUniversalLink = connectionOptions.userActivities.first?.webpageURL {
NTrackerExt.setInflow(url: urlUniversalLink)
}

// Custom URL Scheme. App is not running
if let urlCustomScheme = connectionOptions.urlContexts.first?.url {
NTrackerExt.setInflow(url: urlCustomScheme)
}

// Your Codes.
}

func scene(_ scene: UIScene,
continue userActivity: NSUserActivity) {
// Universal Link URL. App is running or suspended in memory
if userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let urlUniversalLink = userActivity.webpageURL {
NTrackerExt.setInflow(url: urlUniversalLink)
}

// Your Codes.
}

func scene(_ scene: UIScene,
openURLContexts URLContexts: Set<UIOpenURLContext>) {
// Custom URL Scheme. App is running or suspended in memory
if let urlCustomScheme = URLContexts.first?.url {
NTrackerExt.setInflow(url: urlCustomScheme)
}

// Your Codes.
}

}

SwiftUI app

In a SwiftUI app, the code should be as follows:

@main
struct SampleApp: App {

var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
NTrackerExt.setInflow(url: url)
}
}
}

}

Send conversion events

The SDK collects various conversion events.

  • The “App installed” and “App launched” events are automatically collected.
  • The “Purchase completed” event is collected using trackPurchaseEvent, and the “In-app purchase completed” event using trackInAppPurchaseEvent.
  • Other general events are collected using trackConversionEvent.
// Add currency information to “ext1”. “KRW” can be omitted.
let items = [
NTrackerConversionItem(quantity: 1, payAmount: 100, id: "id1", ext1: "KRW"),
NTrackerConversionItem(quantity: 2, payAmount: 400, id: "id2", ext1: "KRW"),
NTrackerConversionItem(quantity: 3, payAmount: 900, id: "id3", ext1: "KRW")
]

// When passing both the conversion value and purchased items
NTrackerExt.trackPurchaseEvent(value: 1_400, items: items)

The general event names are defined in NTrackerConversionEvent.

NTrackerExt.trackConversionEvent(NTrackerConversionEvent.Subscribe, value: 1_000)

For more information, see Send conversion events in How to integrate the SDK.