Switch from Fabric Answers to Google Analytics

Welcome to Google Analytics! Google Analytics provides the same features you had in Fabric and also allows you to integrate your events data with other services in Firebase, such as Firebase Crashlytics and Firebase Cloud Messaging.

This page describes how to switch from Fabric Answers to Google Analytics in your migrated app. You can also review answers to our most frequently asked questions.

Before you begin

If you haven’t already, add Google Analytics to your app.

Step 1: Replace Answers events with Analytics events

In your Xcode workspace, replace all calls to Answers events with the Analytics event equivalent. Use the conversion table below to make your changes:

Answers event Analytics event (Swift) Analytics event (Objective-C)
logPurchaseWithPrice AnalyticsEventEcommercePurchase kFIREventAddToCart
logAddToCartWithPrice AnalyticsEventAddToCart kFIREventAddToCart
logStartCheckoutWithPrice AnalyticsEventBeginCheckout kFIREventBeginCheckout
logContentViewWithName AnalyticsEventViewItem kFIREventViewItem
logSearchWithQuery AnalyticsEventSearch kFIREventSearch
logShareWithMethod AnalyticsEventShare kFIREventShare
logRating No direct equivalent No direct equivalent
logSignUpWithMethod AnalyticsEventSignUp kFIREventSignUp
logLoginWithMethod AnalyticsEventLogin kFIREventLogin
logInviteWithMethod No direct equivalent No direct equivalent
logLevelStart AnalyticsEventLevelStart kFIREventLevelStart
logLevelEnd AnalyticsEventLevelEnd kFIREventLevelEnd

For example, replace:

Swift

Answers.logShareWithMethod("Twitter",
  contentName: "Answers named #2 in Mobile Analytics",
  contentType: "tweet",
  contentId: "601072000245858305",
  customAttributes: nil)
    

Objective-C

[Answers logShareWithMethod:@"Twitter"
    contentName: @"Answers named #2 in Mobile Analytics",
    contentType: @"tweet",
    contentId: @601072000245858305,
    customAttributes: @{}];
    

with:

Swift

Analytics.logEvent("AnalyticsEventShareWithMethod", parameters: [
  AnalyticsParameterName: "Twitter",
  AnalyticsParameterContentName: "Answers named #2 in Mobile Analytics",
  AnalyticsParameterContentType: "tweet",
  AnalyticsParameterContentId: "601072000245858305",
  AnalyticsParameterCustomAttributes: nil])
    

Objective-C

[FIRAnalytics logEventWithName:@"AnalyticsEventShareWithMethod"
    parameters: @{
        AnalyticsParameterName: @"Twitter",
        AnalyticsParameterContentName: @"Answers named #2 in Mobile Analytics",
        AnalyticsParameterContentType: @"tweet",
        AnalyticsParameterContentId: @601072000245858305,
        AnalyticsParameterCustomAttributes: @{}}];
    

Step 2: Disable Answers reporting from Fabric

After you replace your old Answers events with Google Analytics events, we recommend that you disable Answers reporting in Fabric so that your app doesn’t make multiple network calls for the same event.

  1. On your Fabric Dashboard, click Settings > Apps.

  2. Select your app, then click Disable Analytics.

Your app is now configured to use Google Analytics.

Frequently asked questions

I switched my app from using Fabric Answers to Google Analytics. Why aren’t my metrics lining up?

You may see discrepancies in your metrics (for example, your app’s monthly active users) because Fabric and Firebase use different SDKs to calculate crash- free user statistics and metrics. The Fabric SDKs are powered by Answers, whereas the Firebase SDKs are powered by Google Analytics.

Several things may cause Answers to discard events that might lead to a session. For example, as long as an app switches to a foreground state within 30 seconds of being backgrounded, Answers reports all states as a single session as opposed to separate sessions. If something occurs that prevents a background event from being detected, Answers does not count the prior foregrounding event as part of the session.

With Google Analytics, however, a user_engagement event must be triggered to capture activity. A user_engagement event is triggered when a user interacts with the app for a minimum duration (set to 10 seconds by default), which you can control by calling setMinimumSessionDuration(). As long as an app switches to a foreground state within 30 minutes of being backgrounded, Google Analytics counts both states as part of the same session.

In many instances, Answers might count more sessions and users than Google Analytics because Answers requires an app to spend less time in a foreground or background state before it captures a session or an active user. This results in small discrepancies for high-volume apps and potentially larger discrepancies for low-volume apps that manage fewer users and sessions per day.

After I switch to Google Analytics, will I still be able to access my old Answers data?

Your Answers events data does not migrate with your app onto Firebase. After you switch to Google Analytics, your Answers events data will be available on the Fabric Dashboard until you disable Answers. If you want to save your Answers events data, you can visit the Fabric Dashboard before disabling Answers reporting to download your Answers data as a CSV file. Note that the CSV file only contains up to a year’s worth of data and can only be downloaded for specific charts.

There's a specific Answers event in my app and I can't find the equivalent Analytics event to replace it with. What should I do?

You can find all predefined events for Google Analytics and instructions on creating custom event types in the FirebaseAnalytics Framework reference documentation (Swift or Objective-C).