简体   繁体   English

Android使用Firebase Analytics和Google Analytics

[英]Android Using Firebase Analytics along with Google Analytics

I'd love to know how I can use Firebase Analytics (FA) and Google Analytics (GA) simultaneously as FA doesn't provide real-time data and my apps already integrated with GA since the beginning. 我很想知道如何同时使用Firebase Analytics(FA)和Google Analytics(GA),因为FA不提供实时数据,我的应用程序从一开始就已经与GA集成。 I'd like to continue using GA since all my analytic data started there when I first launched my apps. 我想继续使用GA,因为当我第一次启动应用程序时,我的所有分析数据都从那里开始。 Meanwhile, I'd like to have my apps have FA integrated to get more info. 同时,我想让我的应用程序集成FA以获取更多信息。

I followed Using Firebase Analytics and Google Analytics together and setup Google Tag Manager. 我一起关注使用Firebase Analytics和Google Analytics并设置了Google跟踪代码管理器。 It doesn't seem to be working for me. 它似乎对我不起作用。 I do see FA dashboard being updated but nothing is showing up in GA. 我确实看到FA仪表板正在更新,但GA中没有显示任何内容。

Any help is greatly appreciated! 任何帮助是极大的赞赏!

You should use the google-services.json that is supplied for your app in the Firebase console. 您应该使用Firebase控制台中为您的应用提供的google-services.json。 If this is missing your GA tracking ID, you can supply it manually either in your call to newTracker or as a string resource. 如果缺少GA跟踪ID,您可以在调用newTracker时手动提供它,也可以作为字符串资源提供。

In FireBase console, don't CREATE NEW APP, just IMPORT GOOGLE APP. 在FireBase控制台中,不要创建新的APP,只需IMPORT GOOGLE APP。 Let import your current google analytic's app. 让我们导入您当前的谷歌分析应用程序。 Then replace your old config file by new firebase's config file. 然后用新的firebase的配置文件替换旧的配置文件。 Enjoy! 请享用!

Here is a sample of common XML/Plist taken from Firebase: 以下是从Firebase获取的常见XML / Plist示例:

What I have done to obtain this file: 我为获取此文件所做的工作:

1- Implemented Google Analytics for Android and created a project in Google API Console, then 1-实施Android版Google Analytics,然后在Google API控制台中创建项目

2- Implemented Google Analytics for iOS linked to the same Google API project, then 2-然后,实施链接到同一Google API项目的适用于iOS的Google Analytics

3- Created Firebase Project based on the same Google API project. 3-基于相同Google API项目创建的Firebase项目。

XML Config file for Android: Android的XML配置文件:

{
  "project_info": {
    "project_number": "MYAPP_PROJECT_NUMBER",
    "firebase_url": "MYAPP_FIREBASE_URL",
    "project_id": "MYAPP_PROJECT_ID",
    "storage_bucket": "MYAPP_STORAGE_BUCKET"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "MYAPP_MOBILESDK_APP_ID",
        "android_client_info": {
          "package_name": "MYAPP_PACKAGE_NAME"
        }
      },
      "oauth_client": [
        {
          "client_id": "MYAPP_CLIENT_ID_STARTING_WITH_PROJECT_NUMBER_1",
          "client_type": 1,
          "android_info": {
            "package_name": "MYAPP_PACKAGE_NAME",
            "certificate_hash": "MYAPP_CERT_HASH"
          }
        },
        {
          "client_id": "MYAPP_CLIENT_ID_STARTING_WITH_PROJECT_NUMBER_2_DIFFERENT_THAN_OAUTH_CLIENT_ID_ABOVE",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "MYAPP_CURRENT_KEY"
        }
      ],
      "services": {
        "analytics_service": {
          "status": 2,
          "analytics_property": {
            "tracking_id": "MYAPP_TRACKING_ID_FROM_GOOGLE_ANALYTICS"
          }
        },
        "appinvite_service": {
          "status": 1,
          "other_platform_oauth_client": []
        },
        "ads_service": {
          "status": 2
        }
      }
    }
  ],
  "configuration_version": "1"
}

Plist Config file for iOS: 适用于iOS的Plist配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>AD_UNIT_ID_FOR_BANNER_TEST</key>
    <string>MYAPP_AD_UNIT_ID_FOR_BANNER_TEST</string>
    <key>AD_UNIT_ID_FOR_INTERSTITIAL_TEST</key>
    <string>MYAPP_AD_UNIT_ID_FOR_INTERSTITIAL_TEST</string>
    <key>TRACKING_ID</key>
    <string>MYAPP_TRACKING_ID</string>
    <key>CLIENT_ID</key>
    <string>MYAPP_CLIENT_ID</string>
    <key>REVERSED_CLIENT_ID</key>
    <string>MYAPP_REVERSED_CLIENT_ID</string>
    <key>API_KEY</key>
    <string>MYAPP_CURRENT_KEY</string>
    <key>GCM_SENDER_ID</key>
    <string>MYAPP_PROJECT_NUMBER</string>
    <key>PLIST_VERSION</key>
    <string>1</string>
    <key>BUNDLE_ID</key>
    <string>MYAPP_BUNDLE_ID</string>
    <key>PROJECT_ID</key>
    <string>MYAPP_PROJECT_ID</string>
    <key>STORAGE_BUCKET</key>
    <string>MYAPP_STORAGE_BUCKET</string>
    <key>IS_ADS_ENABLED</key>
    <true/>
    <key>IS_ANALYTICS_ENABLED</key>
    <true/>
    <key>IS_APPINVITE_ENABLED</key>
    <false/>
    <key>IS_GCM_ENABLED</key>
    <true/>
    <key>IS_SIGNIN_ENABLED</key>
    <true/>
    <key>GOOGLE_APP_ID</key>
    <string>MYAPP_MOBILESDK_APP_ID</string>
    <key>DATABASE_URL</key>
    <string>MYAPP_FIREBASE_URL</string>
</dict>
</plist>

您可以安全地在Android和iOS应用中同时使用Firebase Analytics和Google Analytics。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM