Google Analytics thu thập và phân tích thông tin về người dùng của bạn. Điều này có thể
giúp bạn nhắm đến các nhóm người dùng cụ thể bằng trải nghiệm ứng dụng phù hợp với họ hơn.
trong trường hợp này là trải nghiệm quảng cáo trong ứng dụng.
Thêm SDK Google Analytics cho Firebase vào ứng dụng
Để sử dụng Google Analytics với AdMob và Firebase, bạn cần thêm thuộc tính
SDK Google Analytics cho Firebase với cơ sở mã của ứng dụng.
SDK này sẽ tự động ghi lại một số sự kiện và phương diện người dùng nhất định; không
bạn cần phải thêm bất kỳ mã nào để bật chúng. Google Analytics sẽ sử dụng dữ liệu này để
phân khúc người dùng thành các đối tượng.
Lưu ý rằng ứng dụng của bạn phải có SDK Google Mobile Ads (AdMob) từ
ở bước trước của hướng dẫn này.
Swift
Thêm và cài đặt nhóm Google Analytics cho Firebase trong tệp pod của bạn:
pod'Firebase/Analytics'
Android
Thêm phần phụ thuộc thư viện Google Analytics cho Firebase vào
Tệp build.gradle:
Từ thư mục gốc của dự án Flutter, hãy chạy lệnh sau để cài đặt
trình bổ trợ Google Analytics cho Firebase:
flutter pub add firebase_analytics
Unity
Tải xuống và cài đặt phiên bản mới nhất
Firebase Unity SDK, rồi thêm
gói Google Analytics cho Firebase vào dự án của bạn: FirebaseAnalytics.unitypackage
Tìm hiểu về đối tượng Google Analytics
Bằng cách sử dụng Google Analytics, bạn có thể phân khúc người dùng của mình thành đối tượng, chính là
các nhóm người dùng có cùng thuộc tính. Tất cả người dùng trong một đối tượng nhất định
đã thể hiện hành vi tương tự trong ứng dụng của bạn (ví dụ: đã thêm một mục vào
giỏ hàng) và/hoặc chia sẻ dữ liệu nhân khẩu học hoặc dữ liệu mô tả khác (ví dụ: độ tuổi
dải ô).
Google Analytics tự động cung cấp thông tin về "Người mua" Đây là đối tượng mặc định.
phổ biến đối với hầu hết các ứng dụng. Bất kỳ người dùng nào đã thực hiện giao dịch mua hàng trong ứng dụng hoặc thương mại điện tử
giao dịch mua hàng sẽ được đặt trong đối tượng này.
Khi sử dụng chiến lược kiếm tiền kết hợp, bạn không muốn hiển thị quảng cáo trong ứng dụng
quảng cáo đến người dùng đã mua hàng. Để bạn có thể tận dụng công cụ Google Analytics này,
đối tượng của "Người mua" khi bạn thiết lập Firebase Remote Config.
Dưới đây là một số tài nguyên Google Analytics để tìm hiểu thêm về đối tượng:
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-09-04 UTC."],[],[],null,["Step 2: Set up Google Analytics\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------------|\n| Introduction: [Optimize hybrid monetization using AdMob, Google Analytics, and Firebase](/docs/tutorials/optimize-hybrid-monetization) |\n| Step 1: Use AdMob to create new ad units for display |\n| **Step 2: [Set up Google Analytics](/docs/tutorials/optimize-hybrid-monetization/step-2)** \u003cbr /\u003e |\n| Step 3: [Set up Firebase Remote Config to show specific ads experiences](/docs/tutorials/optimize-hybrid-monetization/step-3) |\n\n\u003cbr /\u003e\n\nGoogle Analytics collects and analyzes information about your users, which can\nhelp you target specific groups of users with more customized app experiences ---\nin this case, their in-app ads experience.\n\n**Add the Google Analytics for Firebase SDK to your app**\n\nTo use Google Analytics with AdMob and Firebase, you need to add the\nGoogle Analytics for Firebase SDK to your app's codebase.\n\nThis SDK will automatically log certain events and user dimensions; you don't\nneed to add any code to enable them. Google Analytics will use this data to\nsegment your users into audiences.\n\nNote that your app should already have the Google Mobile Ads (AdMob) SDK from\nthe previous step of this tutorial. \n\nSwift\n\nAdd and install the Google Analytics for Firebase pod in your podfile: \n\n pod 'Firebase/Analytics'\n\nAndroid\n\nAdd the Google Analytics for Firebase library dependency to your\n`build.gradle` file: \n\n implementation 'com.google.firebase:firebase-analytics:23.0.0'\n\nFlutter\n\nFrom the root of your Flutter project, run the following command to install\nthe Google Analytics for Firebase plugin: \n\n flutter pub add firebase_analytics\n\nUnity\n\nDownload and install the latest\n[Firebase Unity SDK](https://firebase.google.com/download/unity), and then add\nthe Google Analytics for Firebase package to your project: \n\n`FirebaseAnalytics.unitypackage`\n\n**Understand Google Analytics audiences**\n\nUsing Google Analytics, you can segment your users into **audiences**, which are\ngroups of users who share the same attributes. All the users in a given audience\nhave exhibited the same behavior in your app (for example, added an item to\ncart) and/or share demographic or other descriptive data (for example, age\nrange).\n\nGoogle Analytics automatically provides a \"Purchasers\" default audience that's\ncommon for most apps. Any user who has made an in-app purchase or an ecommerce\npurchase will be placed in this audience.\n\nWhen using a hybrid monetization strategy, you do **not** want to show in-app\nads to users who have made a purchase. So you can leverage this Google Analytics\naudience of \"Purchasers\" when you set up Firebase Remote Config.\n\nHere are some Google Analytics resources to learn more about audiences:\n\n- [Introduction to audiences in Google Analytics](https://support.google.com/analytics/answer/12799087)\n\n- [Examples of audiences in Google Analytics and how to create them](https://support.google.com/analytics/answer/12799863)\n\nIn the next step of this tutorial, you'll leverage the \"Purchasers\" audience in\nsetting up Firebase Remote Config.\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\n\u003cbr /\u003e\n\n[arrow_back_ios**Step 1** : Use AdMob to create new ad units for display](/docs/tutorials/optimize-hybrid-monetization)\n[**Step 3** : Set up Remote Config to show specific ads experiences\narrow_forward_ios](/docs/tutorials/optimize-hybrid-monetization/step-3)\n\n\u003cbr /\u003e\n\n*** ** * ** ***"]]