LoginSignup
4
1

More than 5 years have passed since last update.

Firebaseイベント取得について(Swift3.0)

Posted at

モバイル解析のためGoogle Analyticsを設定しようと思ったら既にトラッキング方法がFirebaseしか選べなくなっていました・・・
(2017/05/24時点)

スクリーンショット 2017-05-25 2.02.32.png

いい機会だったので、Firebaseで頑張ってみることに。

Firebase Analytics for iOS を使ってみる

公式ドキュメントとほぼ同じ話です

1. podfileに下記行を追加し、pod installを実行

pod 'Firebase/Core'

2. .xcworkspaceを開きAppDelegate.swiftに、Firebaseモジュールのインポートと初期化を追記

import UIKit
import Firebase  <- Firebaseモジュールのインポート

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        FIRApp.configure() <- Firebase初期化

        return true
    }
(以下略)

3. イベントを取得したい場所にlogEventメソッドを記載

FIRAnalytics.logEvent(withName: "share_image", parameters: [
  "name": name as NSObject,
  "full_text": text as NSObject
  ])
  • withNameの引数がイベント名
  • "name", "full_text"はカスタムパラメータ

実際にanalyticsの画面でイベントが取得できていれば成功です。
(ただし、表示の反映が数時間後・・・)
スクリーンショット_2017-05-25_0_24_45.jpg

カスタムパラメータの扱い

  • logEventに追加したカスタムパラメータの値の集計をしたかったが、Firebase Analytics上ではあちこちいじってもそれらしい方法が見つからなかった
  • どうやらlogEventの集計は、現状BigQueryを使用しないとできないらしい。改善方法を模索中とのこと。
(引用)
しかし、現在(BigQuery を使わずに)できないことの 1 つが、
Firebase Analytics イベントで送信したカスタム パラメータに設定されている値を確認することです。

まとめ

BigQueryを使うほどではないデータ数のイベントであれば、Analyticsの画面上でパッと確認できると嬉しいです。続報に期待します。

4
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
4
1