LoginSignup
3
1

More than 5 years have passed since last update.

MetapsAnalyticsの導入

Last updated at Posted at 2018-12-21

はじめに

アイエンター #1 Advent Calendar 2018、22日目の記事を担当しますNecorinです。

Analyticsといえば、Googleくらいしか思いつきませんが、Metaps Analyticsなるものがあるらしい。
案件都合でiOSアプリに導入することになったので備忘録として書き留めておきます。

導入方法

1. AnalyticsSDKの導入

CocoaPodsに下記内容を記載

pod 'analytics-ios'

※ Frameworkを直接追加する方法もありますが割愛します。

2. AnalyticsSDKの初期化・計測

AppDelegate.swift

import UIKit
import AnalyticsSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Analytics Framework の初期設定
        Metaps.initialize("applicationID")

        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // 計測の終了
        MetapsAnalytics.stop()
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // 計測の開始
        MetapsAnalytics.start()
    }
}

これで導入は終了です。
あとは適当なタイミングで購入処理や独自のイベントを計測することが可能になります。

3. デバッグログ表示

// デバッグログの有効化
MetapsAnalytics.enableLog(true)

4. 購入イベントの計測

// 購入処理の計測
MetapsAnalytics.trackPurchase("任意の文字列", price: "金額", currency: "JPY")

まとめ

公式のドキュメントがしっかりしており、かなり簡単に導入することができた。
今度はGoogleAnalyticsを使ってみたいと思う。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1