Để bắt đầu, trước tiên, bạn cần tạo một đơn vị quảng cáo mới, sau đó triển khai quảng cáo trong mã của ứng dụng.
Hướng dẫn này sử dụng định dạng quảng cáo xen kẽ làm định dạng mới đang được thử nghiệm để áp dụng. Tuy nhiên, khi đọc hướng dẫn này, hãy lưu ý rằng bạn có thể làm theo các bước tương tự để triển khai và kiểm thử bất kỳ định dạng quảng cáo nào khác.
Đảm bảo bạn đáp ứng các điều kiện tiên quyết để tham gia hướng dẫn này
Ứng dụng của riêng bạn (dự án iOS, Android, Flutter hoặc Unity)
Ứng dụng của bạn được đăng ký dưới dạng một Ứng dụng Firebase được liên kết với một Ứng dụng AdMob
(tìm hiểu thêm).
Điều này có nghĩa là các thao tác sau cũng được thực hiện:
Bạn đã bật Google Analytics trong dự án Firebase (nghĩa là bạn đã liên kết dự án Firebase với một tài sản Google Analytics).
Bạn đã thêm cấu hình Firebase hiện hành vào cơ sở mã của ứng dụng.
Quyền truy cập vào tài khoản AdMob được liên kết của ứng dụng, có quyền tạo
đơn vị quảng cáo mới
Có quyền truy cập vào dự án Firebase được liên kết của ứng dụng, có quyền tạo và quản lý Firebase Remote Config
Quyền truy cập vào tài sản Google Analytics được liên kết với dự án Firebase của bạn, với các quyền tạo đối tượng (ít nhất là vai trò Người chỉnh sửa)
Môi trường phát triển tích hợp (IDE) mà bạn muốn sử dụng
Tạo đơn vị quảng cáo trong tài khoản AdMob
Trong tài khoản AdMob, hãy làm theo lời nhắc trên màn hình để tạo đơn vị quảng cáo Xen kẽ mà bạn sẽ hiển thị trong ứng dụng.
Các chế độ cài đặt đơn vị quảng cáo khác không quan trọng đối với hướng dẫn cụ thể này, vì vậy, hãy chọn chế độ cài đặt phù hợp với ứng dụng của bạn.
Triển khai đơn vị quảng cáo trong cơ sở mã của ứng dụng
Sau khi bạn tạo một đơn vị quảng cáo, AdMob sẽ cung cấp cho bạn một mã đơn vị quảng cáo duy nhất cho đơn vị quảng cáo đó. Hãy nhớ vị trí tìm thấy mã đơn vị quảng cáo này trong tài khoản AdMob vì bạn sẽ cần mã này để triển khai quảng cáo vào ứng dụng. Nếu đã tạo nhiều đơn vị quảng cáo, bạn sẽ cần mã đơn vị quảng cáo cho mỗi đơn vị quảng cáo.
Làm theo hướng dẫn trên màn hình (hoặc truy cập vào các đường liên kết bên dưới) để tích hợp SDK Google Mobile Ads (AdMob) (nếu bạn chưa tích hợp) và triển khai đơn vị quảng cáo mới vào ứng dụng của bạn.
Trong các bước tiếp theo của hướng dẫn này, bạn sẽ định cấu hình Firebase Remote Config để hiển thị đơn vị quảng cáo này dựa trên việc người dùng có thuộc đối tượng "Người mua hàng" trên Google Analytics hay không.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[],[],null,["Step 1: Use AdMob to create new ad units for display\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** \u003cbr /\u003e |\n| Step 2: [Set up Google Analytics](/docs/tutorials/optimize-hybrid-monetization/step-2) |\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\nTo get started, you first need to create a new ad unit and then implement the ad\nin your app's code.\n\nThis tutorial uses the\n[interstitial](https://support.google.com/admob/answer/7311435) ad\nformat as the new format being tested for adoption. When reading this tutorial,\nthough, keep in mind that you could follow similar steps to implement and test\nany other ad format.\n\n\u003cbr /\u003e\n\n**Make sure you have the prerequisites for this tutorial**\n\n\u003cbr /\u003e\n\n- Your own app (iOS, Android, Flutter, or Unity project)\n\n- Your app registered as a Firebase App that's linked to an AdMob App\n ([learn more](//support.google.com/admob/answer/6383165)). \n\n This means the following are also done:\n\n - You've enabled Google Analytics in your Firebase project (meaning you've\n linked your Firebase project to a Google Analytics property).\n\n - You've added the applicable Firebase configuration to your app's codebase.\n\n- *(Android apps or apps targeting Android)*\n [Link your Firebase App to Google Play](https://support.google.com/firebase/answer/6392038)\n (required to get in-app purchase event data)\n\n- Access to your app's associated AdMob account, with permissions to create\n new ad units\n\n- Access to your app's associated Firebase project, with permissions to create\n and manage Firebase Remote Config\n\n- Access to the Google Analytics property linked to your Firebase project, with\n permissions to create audiences (at least Editor role)\n\n- Your preferred IDE\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n**Create an ad unit in your AdMob account**\n\nIn your\n[AdMob account](https://apps.admob.com), follow the on-screen\nprompts to create an *Interstitial* ad unit that you will display in your app.\n\nThe other ad unit settings aren't important for this particular tutorial, so\nselect settings that are appropriate for your app.\n| **Important:** For Flutter projects and Unity projects, you need to create a separate interstitial ad unit in each of your AdMob Apps; one for each platform that you target (that is, Android and iOS).\n\n**Implement the ad unit in your app's codebase**\n\nAfter you create an ad unit, AdMob provides you with a unique **ad unit ID**\nfor the ad unit. Remember where to find this ad unit ID in your AdMob\naccount as you'll need it to implement the ad into your app. If you created more\nthan one ad unit, then you'll need the ad unit ID for *each* ad unit.\n\nFollow the on-screen instructions (or go to the links below) to integrate the\nGoogle Mobile Ads (AdMob) SDK (if you haven't already) and to implement the\nnew ad unit into your app. \n\nSwift\n\n1. [Get started with AdMob in an iOS app](https://developers.google.com/admob/ios/quick-start)\n2. [Implement interstitial ads in an iOS app](https://developers.google.com/admob/ios/interstitial)\n\nKotlin\n\n1. [Get started with AdMob in an Android app](https://developers.google.com/admob/android/quick-start)\n2. [Implement interstitial ads in an Android app](https://developers.google.com/admob/android/interstitial)\n\nJava\n\n1. [Get started with AdMob in an Android app](https://developers.google.com/admob/android/quick-start)\n2. [Implement interstitial ads in an Android app](https://developers.google.com/admob/android/interstitial)\n\nFlutter\n\n1. [Get started with AdMob in a Flutter app](https://developers.google.com/admob/flutter/quick-start)\n2. [Implement interstitial ads in a Flutter app](https://developers.google.com/admob/flutter/interstitial)\n\nUnity\n\n1. [Get started with AdMob in a Unity app](https://developers.google.com/admob/unity/quick-start)\n2. [Implement interstitial ads in a Unity app](https://developers.google.com/admob/unity/interstitial)\n\nIn the next steps of this tutorial, you'll configure Firebase Remote Config\nto display this ad unit based on whether a user is part of the Google Analytics\naudience of \"Purchasers\".\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\n\u003cbr /\u003e\n\n[arrow_back_ios**Introduction**](/docs/tutorials/optimize-hybrid-monetization)\n[**Step 2** : Set up Google Analytics\narrow_forward_ios](/docs/tutorials/optimize-hybrid-monetization/step-2)\n\n\u003cbr /\u003e\n\n*** ** * ** ***"]]