This guide contains instructions for the latest version of the Firebase Crashlytics SDK. If you migrated your app from Fabric, make sure you're upgraded to the latest SDK.

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.

Step 1: Add Google Analytics

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

Step 2: 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: @{}}];
    

Frequently asked questions

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).