שלב 3: הגדרת Firebase Remote Config להצגת חוויות צפייה ספציפיות במודעות
| מבוא: אופטימיזציה של מודל מונטיזציה משולב באמצעות AdMob, Google Analytics ו-Firebase |
| שלב 1: משתמשים ב-AdMob כדי ליצור יחידות חדשות של מודעות לרשת המדיה |
| שלב 2: מגדירים את Google Analytics |
|
שלב 3: הגדרת Firebase Remote Config להצגת חוויות צפייה ספציפיות במודעות |
בסוף השלב הקודם למדתם על קהלים ב-Google Analytics. בשלב הזה, יוצרים Remote Configפרמטר עם ערך בוליאני (boolean) (שנקרא ad_control_switch) שמבוסס על הקהל 'רוכשים'. לאחר מכן, מוסיפים את הלוגיקה לקוד של האפליקציה כדי לקבוע מה יוצג באפליקציה על סמך הערך של הפרמטר הזה.
הגדרת פרמטרים ותנאים של Remote Config במסוף Firebase
במסוף Firebase, פותחים את פרויקט Firebase.
בחלונית הימנית, מרחיבים את הקטע Engage ובוחרים באפשרות Remote Config.
לוחצים על יצירת הגדרה (או על הוספת פרמטר אם השתמשתם ב-Remote Config בעבר).
בחלונית Create parameter (יצירת פרמטר), מבצעים את הפעולות הבאות:
בשדה שם הפרמטר, מזינים
ad_control_switch.בתפריט הנפתח
Data type, בוחרים באפשרות Boolean (בוליאני).לוחצים על יצירת תנאי חדש ואז על יצירת תנאי חדש.
בתיבת הדו-שיח הגדרת תנאי חדש, מבצעים את הפעולות הבאות:
בשדה Name, מזינים
Purchasers Group(או כל שם אחר שקל לזהות את התנאי).בתפריט הנפתח התנאי חל אם..., בוחרים באפשרות קהלים של משתמשים.
בתפריט הנפתח בחירת קהלים, בוחרים באפשרות רוכשים.
לוחצים על שמירת התנאי.
בחזרה לחלונית Create parameter, מבצעים את הפעולות הבאות:
בקטע Value של Purchasers Group, בוחרים באפשרות false.
בקטע ערך ברירת מחדל, בוחרים באפשרות true.
לוחצים על שמירה ואז על פרסום השינויים.
ההגדרה הזו תבדוק אם המשתמש נכלל בקהל 'רוכשים' (כלומר, אם הוא משתמש משלם):
אם המשתמש נמצא בקהל 'רוכשים', הפונקציה Remote Config תחזיר את הערך של
falseעבור הפרמטרad_control_switch.אם המשתמש לא נכלל בקהל 'רוכשים', הפונקציה Remote Config תחזיר את הערך של
trueעבור הפרמטרad_control_switch.
בשלבים הבאים תטמיעו את Remote Config באפליקציה כדי לטפל בערכי הפרמטרים האלה.
הוספת Remote Config SDK לאפליקציה
לפני שמשתמשים ב-Remote Config בקוד האפליקציה, צריך להוסיף את Remote Config SDK לבסיס הקוד של האפליקציה. שימו לב שהאפליקציה שלכם כבר צריכה לכלול את Google Mobile Ads (AdMob) SDK ואת Google Analytics for Firebase SDK מהשלבים הקודמים של המדריך הזה.
Swift
מוסיפים ומתקינים את ה-Pod Remote Config ב-Podfile:
pod 'Firebase/RemoteConfig'
Android
מוסיפים את התלות בספריית Remote Config לקובץ build.gradle:
implementation 'com.google.firebase:firebase-config:23.1.0'
Flutter
מהרמה הבסיסית (root) של פרויקט Flutter, מריצים את הפקודה הבאה כדי להתקין את הפלאגין Remote Config:
flutter pub add firebase_remote_config
Unity
מורידים ומתקינים את הגרסה האחרונה של Firebase Unity SDK, ואז מוסיפים את חבילת Remote Config לפרויקט:
FirebaseRemoteConfig.unitypackage
הגדרת מופע Remote Config
כדי שהאפליקציה תוכל להשתמש בערכי הפרמטרים Remote Config, צריך להגדיר את המופע Remote Config כך שיוכל לאחזר ערכים חדשים עבור מופע אפליקציית הלקוח.
בדוגמה הזו, Remote Config מוגדר לבדוק אם יש ערכים חדשים של פרמטרים פעם בשעה.
Swift
remoteConfig = RemoteConfig.remoteConfig()
let settings = RemoteConfigSettings()
settings.minimumFetchInterval = 3600
remoteConfig.configSettings = settings
Kotlin
remoteConfig = Firebase.remoteConfig
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = 3600
}
remoteConfig.setConfigSettingsAsync(configSettings)
Java
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setMinimumFetchIntervalInSeconds(3600)
.build();
mFirebaseRemoteConfig.setConfigSettingsAsync(configSettings);
Flutter
remoteConfig = FirebaseRemoteConfig.instance;
final configSettings = FirebaseRemoteConfigSettings(
minimumFetchInterval: Duration(hours: 1),
);
await remoteConfig.setConfigSettings(configSettings);
// Use the `onConfigUpdated` callback to listen for changes to the config settings.
remoteConfig.onConfigUpdated.listen((_) {
print('Config settings confirmed');
});
Unity
var remoteConfig = FirebaseRemoteConfig.DefaultInstance;
var configSettings = new ConfigSettings {
MinimumFetchInternalInMilliseconds =
(ulong)(new TimeSpan(1, 0, 0).TotalMilliseconds)
};
remoteConfig.SetConfigSettingsAsync(configSettings)
.ContinueWithOnMainThread(task => {
Debug.Log("Config settings confirmed");
}
מאחזרים ומפעילים Remote Config
מאחזרים ומפעילים את הפרמטר Remote Config כדי להתחיל להשתמש בערכי הפרמטרים החדשים.
כדאי שתבצעו את ההפעלה בשלב מוקדם ככל האפשר של טעינת האפליקציה, מכיוון שההפעלה הזו היא אסינכרונית ותצטרכו לאחזר מראש את הערך של Remote Config כדי שהמערכת תדע אם להציג מודעה באפליקציה.
Swift
remoteConfig.fetch() { (status, error) -> Void in
if status == .success {
print("Config fetched!")
self.remoteConfig.activate() { (changed, error) in
// ...
}
} else {
print("Config not fetched")
print("Error: \(error?.localizedDescription ?? "No error available.")")
}
self.loadAdUnit()
}
Kotlin
remoteConfig.fetchAndActivate()
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
val updated = task.result
Log.d(TAG, "Config params updated: $updated")
} else {
Log.d(TAG, "Config params failed to update")
}
loadAdUnit()
}
Java
mFirebaseRemoteConfig.fetchAndActivate()
.addOnCompleteListener(this, new OnCompleteListener<Boolean>() {
@Override
public void onComplete(@NonNull Task<Boolean> task) {
if (task.isSuccessful()) {
boolean updated = task.getResult();
Log.d(TAG, "Config params updated: " + updated);
} else {
Log.d(TAG, "Config params failed to update");
}
loadAdUnit();
}
});
Flutter
remoteConfig = FirebaseRemoteConfig.instance;
// Fetch and activate the latest Remote Config values.
final updated = await remoteConfig.fetchAndActivate();
// Check if the config params were updated successfully.
if (updated) {
print('Config params updated');
} else {
print('Config params failed to update');
}
// Load the ad unit.
_loadAdUnit();
Unity
remoteConfig.FetchAndActivateAsync().ContinueWithOnMainThread(task => {
if (task.IsFaulted) {
Debug.LogWarning("Config params failed to update");
} else {
Debug.Log("Config params updated: " + task.Result);
}
LoadAdUnit();
});
האפליקציה מוגדרת עכשיו לטיפול בפרמטר Remote Config שיצרתם קודם בשלב הזה.
שימוש בערך הפרמטר Remote Config
משתמשים בערך Remote Config שאוחזר מראש בפונקציה loadAdUnit() כדי לקבוע אם מופע האפליקציה צריך לבצע אחת מהפעולות הבאות:
הערך של הפרמטר
ad_control_switchהואtrue: המודעה הבין-דף תוצג (כי המשתמש הוא לא משתמש משלם).הערך של הפרמטר
ad_control_switchהואfalse: לא להציג את המודעה (כי המשתמש הוא משתמש משלם).
Swift
private func loadAdUnit() {
let showAds = remoteConfig["ad_control_switch"].boolValue
if showAds {
// Load interstitial ad (implemented ad unit)
// per AdMob instructions (the first step of this tutorial).
} else {
// Don't show ads.
}
}
Kotlin
private fun loadAdUnit() {
var showAds = remoteConfig.getBoolean(ad_control_switch)
if (showAds) {
// Load interstitial ad (implemented ad unit)
// per AdMob instructions (the first step of this tutorial).
} else {
// Don't show ads.
}
}
Java
private void loadAdUnit() {
boolean showAds =
mFirebaseRemoteConfig.getBoolean(ad_control_switch);
if (showAds) {
// Load interstitial ad (implemented ad unit)
// per AdMob instructions (the first step of this tutorial).
} else {
// Don't show ads.
}
}
Flutter
void _loadAdUnit() {
bool showAds = remoteConfig.getBool(ad_control_switch);
if (showAds) {
// Load interstitial ad (implemented ad unit)
// per AdMob instructions (the first step of this tutorial).
} else {
// Don't show ads.
}
}
Unity
void LoadAdUnit() {
bool showAds =
remoteConfig.GetValue("ad_control_switch").BooleanValue;
if (showAds) {
// Load interstitial ad (implemented ad unit)
// per AdMob instructions (the first step of this tutorial).
} else {
// Don't show ads.
}
}
השקת האפליקציה
הלוגיקה להצגת המודעה או לא נמצאת בבסיס הקוד שלכם, ולכן אתם צריכים לפרסם גרסה חדשה של האפליקציה שמכילה את הלוגיקה הזו.
אם פעלתם לפי השלבים במדריך הזה, המערכת תתחיל להציג למשתמשים באפליקציה שלכם חוויית שימוש מותאמת אישית במודעות באופן מיידי. אתם יכולים לעקוב אחרי ההכנסות ממודעות גם בחשבון AdMob וגם בלוחות הבקרה של Google Analytics (במסוף Firebase או בממשק המשתמש של Google Analytics).
זהו, סיימתם. סיימתם את המדריך לאופטימיזציה של מונטיזציה היברידית באמצעות AdMob, Google Analytics ו-Firebase.
מקורות מידע שקשורים לנושא
כדאי לעיין במדריכים נוספים לפתרון בעיות:
אפשר לצפות בסדרת סרטונים: אופטימיזציה של ההכנסות מהאפליקציה באמצעות Firebase ו-AdMob