Use more features of Google Analytics and Firebase with AdMob apps
Stay organized with collectionsSave and categorize content based on your preferences.
After completing the basicAdMobsetup, you can also add the Firebase SDK
forGoogle Analyticsto take advantage of other features fromGoogle Analyticsand Firebase. Learn how toget started withGoogle Analyticslater on this page.
These increasing levels of configuration support features that can help you
optimize your app's user experience and your ad revenue. Check out the following
table of features and its links to learn more!
Feature
AddMobile AdsSDK + enable user metrics
AddMobile AdsSDK + enable user metricsand LinkAdMobto Firebase
Google Analyticsis Firebase's analytics engine that gives you access to
powerful insights into your data. Start usingGoogle Analyticsin your app
by adding the Firebase SDK forGoogle Analytics.
Why add the Firebase SDK forGoogle Analytics?
With thebasicAdMobsetup, you can view
aggregated statistics from automatically collectedeventsanduser propertiesin theAnalyticsdashboard of theFirebaseconsole without adding any
additional code to your app.
However, if you want to collect additionalcustomevent data or user
properties, you'll need to use the Firebase SDK forGoogle Analytics. With
this SDK, you can log up to 500 different analytics event types, and there's no
limit on the total volume of events your app logs. An example use case for
logging custom events is to include data in your revenue calculation from a
custom event calledecommerce_purchaseto help youbetter represent ARPU
and ARPPU
metrics.
The following steps describe how to start using the Firebase SDK forGoogle Analyticsin your app. After initializing the SDK, visit theAnalyticsdocumentationto learn how to start
logging events in your app.
Step 1:Add a configuration file to your app
If you registered your app with Firebase before creating anAdMoblink, then
you already added a Firebase configuration file to your app.
Check for aGoogleService-Info.plistfile in the root of your Xcode project.
Also make sure that the config file is added to all targets.
If you don't have this config file in your app, expand
this section to learn how to add this file.
In theYour appscard of yoursettings>Project settings,
select the bundle ID of the app for which you need a config file.
ClickDownload GoogleService-Info.plistto obtain your Firebase iOS
config file (GoogleService-Info.plist).
You can download your Firebase iOS config file again at any time from yoursettings>Project settings.
Make sure the config file name isn't appended with additional characters,
like(2).
Move your config file into the root of your Xcode project. If prompted,
select to add the config file to all targets.
If you have multiple bundle IDs in your project, you must associate each bundle
ID with a registered app in theFirebaseconsole so that each app can have
its ownGoogleService-Info.plistfile.
Step 2:Add the Firebase SDK forAnalyticsto your app
Add the dependency for the Firebase SDK forGoogle Analyticsto your
Podfile:
pod 'FirebaseAnalytics'
Runpod install, then open the created.xcworkspacefile.
Import theFirebaseCoremodule in yourUIApplicationDelegate, as well as any otherFirebase modulesyour app delegate uses.
For example, to useCloud FirestoreandAuthentication:
Configure aFirebaseAppshared instance in your app delegate'sapplication(_:didFinishLaunchingWithOptions:)method:
SwiftUI
// Use Firebase library to configure APIsFirebaseApp.configure()
Swift
// Use Firebase library to configure APIsFirebaseApp.configure()
Objective-C
// Use Firebase library to configure APIs[FIRAppconfigure];
If you're using SwiftUI, you must create an application delegate and attach it
to yourAppstruct viaUIApplicationDelegateAdaptororNSApplicationDelegateAdaptor. You must also disable app delegate swizzling. For
more information, see theSwiftUI instructions.
SwiftUI
@mainstructYourApp:App{// register app delegate for Firebase setup@UIApplicationDelegateAdaptor(AppDelegate.self)vardelegatevarbody:someScene{WindowGroup{NavigationView{ContentView()}}}}
Implement custom event logging
This section shows an example of how toimplement custom event
loggingin your app. This specific example is for the
custom eventecommerce_purchasewhich is a helpful event to log forAdMob-linked apps, especially for calculating ARPU
and ARPPU
.
Why isecommerce_purchaseimportant for
ARPU and ARPPU?
A key metric for your app isrevenue by
user,
which can be further segmented into ARPU
and ARPPU
. These two metrics
display in theUser metricscard of yourAdMobaccount and in theAnalyticsdashboard of theFirebaseconsole. Revenue, though, isn't
directly measured; instead, it's the sum of yourestimatedAdMobearningsand the following two analytics event values:
in_app_purchase:
when a user completes an in-app purchase that is processed by the App Store on
iTunes, like an initial subscription, unlocking premium services, or buying
in-game items
ecommerce_purchase:
when a user completes a purchase, like online shopping, buying coupons or
discount items, or buying movie tickets
Without any additional code in your app, theMobile AdsSDK
automatically collects analytics data forin_app_purchaseevents. However, if
you want toalsoincludeecommerce_purchaseevent data in the revenue
calculation, you'll need to implement custom logging via the Firebase SDK forGoogle Analytics.
Here's how to implement custom event logging in your app:
Make sure that you've completed theGet started withGoogle Analyticssection of this page,
which includes configuring your app to use Firebase, adding the
Firebase SDK forGoogle Analytics, and initializing the SDK.
Log anecommerce_purchaseevent
(Swift|Obj-C).
Here's an example:
After you add the Firebase SDK forGoogle Analytics, you can also start
using other Firebase products, likeFirebase Remote ConfigandFirebase A/B Testing.
Remote Configenables you to change the behavior
and appearance of your app without publishing an app update, at no cost, for
unlimited daily active users.
A/B Testinggives you the power to test changes to
your app’s UI, features, or engagement campaigns to learn if they make an
impact on your key metrics (like revenue and retention) before rolling the
changes out widely.
Optimize ad monetization for your app
Try out different ad formats or configurations with a small subset of users, and
then make data driven decisions about implementing the ad for all your users. To
learn more, check out the following tutorials:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-05 UTC."],[],[],null,[]]