Introduction
L'API Offerwall Custom Choice vous permet d'intégrer votre propre solution de monétisation personnalisée à l'Offerwall dans Google Ad Manager.
Pour intégrer votre propre solution de monétisation à l'Offerwall, suivez la procédure de configuration des choix personnalisés. En résumé :
Activez l'option "Choix personnalisé" pour votre Offerwall dans l'onglet Confidentialité et messages d'Ad Manager.
Ajoutez du code JavaScript personnalisé entre les balises
<head>
et</head>
du site sur lequel vous avez publié votre Offerwall.Instanciez un objet
CustomOfferwallChoice
comme défini dans les sections suivantes, puis enregistrez-le avec votre Offerwall dans la fenêtre.
Exemple de code
Pour commencer rapidement, consultez cet exemple d'implémentation de l'API Offerwall Custom Choice.
Utilisation de l'API
Un CustomOfferwallChoice
est un objet JavaScript que vous branchez à votre Offerwall pour intégrer votre implémentation de monétisation personnalisée.
// Define your custom choice.
class CustomOfferwallChoice {
// Initialize your custom choice, which may include loading or preparing any
// resources required to function.
async initialize(params: InitializeParams): Promise<InitializeResponseEnum> {...}
// Show your custom choice on the web page, which may be a subscription
// service, micropayments service, rewarded ad, etc.
async show(): Promise<boolean> {...}
}
// Register your custom choice with your Offerwall.
window.googlefc = window.googlefc || {};
window.googlefc.offerwall = window.googlefc.offerwall || {};
window.googlefc.offerwall.customchoice = window.googlefc.offerwall.customchoice || {};
window.googlefc.offerwall.customchoice.registry = new CustomOfferwallChoice();
Définitions des méthodes
Cette section décrit chaque méthode qu'un CustomOfferwallChoice
doit implémenter.
initialize
initialize(params: InitializeParams): Promise<InitializeResponseEnum>
Initialisez votre solution de monétisation personnalisée. Cette fonction est appelée avant toute autre fonction et peut être appelée au maximum une fois lors du chargement d'une page donnée.
Exemple
async initialize(params: InitializeParams): Promise<InitializeResponseEnum> {
// If your custom choice is inoperable on this page, return CUSTOM_CHOICE_DISABLED,
// causing your Offerwall to exclude the custom choice option when rendering.
const isCustomChoiceEnabled: boolean = await this.initializeCustomOfferwallChoice(params);
if (!isCustomChoiceEnabled) {
resolve(googlefc.offerwall.customchoice.InitializeResponseEnum.CUSTOM_CHOICE_DISABLED);
}
// If the user should automatically be granted page access on page load, return
// ACCESS_GRANTED, causing your Offerwall to be ineligible to render on this page.
const isAccessGranted: boolean = await this.shouldUserBeGrantedPageAccess();
if (isAccessGranted) {
resolve(googlefc.offerwall.customchoice.InitializeResponseEnum.ACCESS_GRANTED);
}
// If the user shouldn't automatically be granted page access on page load, return
// ACCESS_NOT_GRANTED, causing your Offerwall to be eligible to render on this page.
resolve(googlefc.offerwall.customchoice.InitializeResponseEnum.ACCESS_NOT_GRANTED);
}
afficher
show(): Promise<boolean>
Affichez votre solution de monétisation personnalisée et gérez les actions de monétisation de l'utilisateur. Cette méthode est appelée par votre Offerwall lorsque l'utilisateur clique sur l'option de choix personnalisé. La monétisation peut prendre différentes formes, y compris un service d'abonnement, un service de micropaiements, une annonce avec récompense, etc. Lorsqu'il est appelé, votre Offerwall est masqué jusqu'à ce que cette promesse soit résolue. Il est de la responsabilité de votre CustomOfferwallChoice
de contrôler l'accès au contenu de la page en attendant. Une fois cette promesse résolue, votre CustomOfferwallChoice
ne doit plus être visible sur la page Web.
Une fois la promesse de la fonction show()
résolue, vous devez :
Masquez votre solution de monétisation affichée.
Renvoie une valeur booléenne indiquant si l'utilisateur a obtenu l'accès au contenu de la page :
true
: l'utilisateur a obtenu l'accès au contenu de la page. Dans ce cas, votre Offerwall ne sera plus affiché une fois la promesse résolue.false
: l'utilisateur n'a pas pu accéder au contenu de la page. Dans ce cas, votre Offerwall sera à nouveau affiché une fois la promesse résolue.
Exemple
async show(): Promise<boolean> {
// Show your custom choice dialog and hide it once the user completes an action.
const didUserGainAccessToPage: boolean = await this.showCustomChoiceDialogUntilUserAction();
resolve(didUserGainAccessToPage);
}
Enregistrement du choix personnalisé
L'enregistrement inclut la transmission de votre objet CustomOfferwallChoice
instancié au registre de fenêtres suivant :
window.googlefc.offerwall.customchoice.registry
Exemple
// Register your custom choice with your Offerwall.
window.googlefc = window.googlefc || {};
window.googlefc.offerwall = window.googlefc.offerwall || {};
window.googlefc.offerwall.customchoice = window.googlefc.offerwall.customchoice || {};
window.googlefc.offerwall.customchoice.registry = new CustomOfferwallChoice();
Définitions de type d'API
Cette section décrit chaque type de données de l'API.
Définitions d'objets
Cette section décrit chaque définition d'objet dans l'API.
InitializeParams
Type d'objet de paramètre pour la fonction initialize.
Propriété | Type | Description |
---|---|---|
offerwallLanguageCode |
string | undefined |
Code de langue de votre Offerwall diffusé, tel que défini par la norme BCP 47. |
Définitions d'énumérations
Cette section décrit chaque définition d'énumération dans l'API.
googlefc.offerwall.customchoice.InitializeResponseEnum
Type d'énumération de la réponse pour la fonction initialize.
Membre de l'énumération | Description |
---|---|
CUSTOM_CHOICE_DISABLED
|
Désactivez l'option de choix personnalisé dans votre message Offerwall. Si le choix personnalisé est désactivé, votre Offerwall ne peut s'afficher qu'avec d'autres choix éligibles. S'il n'y en a aucun, votre Offerwall ne s'affichera jamais sur la page. |
ACCESS_GRANTED |
Accorder l'accès à la page utilisateur lors du chargement de la page. Votre Offerwall ne s'affichera jamais sur la page si cette réponse est renvoyée. |
ACCESS_NOT_GRANTED |
N'accordez pas l'accès à la page à l'utilisateur lors du chargement de la page. Votre Offerwall est éligible à l'affichage sur la page si cette réponse est renvoyée. |