वर्शन: 1.0.0
परिचय
कमाई करने की सुविधा देने वाली कंपनी के क्लाइंट एपीआई की मदद से, Ad Manager में निजता और मैसेज सेवा के साथ, कमाई करने का अपना समाधान इंटिग्रेट किया जा सकता है.
कमाई करने के अपने तरीके को Offerwall के साथ इंटिग्रेट करने के लिए, यह तरीका अपनाएं:
Ad Manager में निजता और मैसेज सेवा टैब में जाकर, Offerwall के लिए "पसंद के मुताबिक विकल्प" चालू करें.
उस साइट पर कस्टम JavaScript जोड़ें जिस पर Offerwall पब्लिश किया गया है. इसे लागू करने से जुड़ी जानकारी, नीचे दिए गए सेक्शन में देखी जा सकती है.
इस JavaScript को, यहां बताए गए तरीके से कमाई करने की सुविधा देने वाली कस्टम कंपनी को इंस्टैंशिएट करना चाहिए. साथ ही, रजिस्ट्रेशन कुंजी:
'publisherCustom'
की मदद से, विंडो पर निजता और मैसेज सेवा के साथ कंपनी को रजिस्टर करना चाहिए.
शब्दावली
शब्द | परिभाषा |
---|---|
कमाई करने की सुविधा देने वाली कंपनी | एक नेटिव JavaScript ऑब्जेक्ट, जो कमाई करने का आपका कस्टम तरीका उपलब्ध कराता है. उदाहरण के लिए, सदस्यता की सेवा, माइक्रो पेमेंट की सेवा वगैरह दी जा सकती है. Offerwall, कॉन्टेंट से कमाई करने के लिए, आपके पसंद के मुताबिक बनाए गए समाधान के साथ, कॉन्टेंट उपलब्ध कराने वाली कंपनी के तरीकों का इस्तेमाल करता है. |
पात्रता | कमाई करने के आपके तरीके से, उपयोगकर्ताओं को कमाई करने से जुड़ी कोई कार्रवाई करने पर मिलने वाला इनाम. इस एपीआई के दायरे में, किसी एनटाइटलमेंट की मदद से उपयोगकर्ताओं को आपकी वेबसाइट के कॉन्टेंट का ऐक्सेस मिलता है. इसके लिए, उन्हें Offerwall नहीं देखना पड़ता. आपके पास यह तय करने का विकल्प होता है कि मुफ़्त में कितने पेज लोड किए जा सकते हैं या कमाई करने के लिए चुने गए कस्टम विकल्प को चुनने वाले उपयोगकर्ताओं को कितनी देर तक ऐप्लिकेशन इस्तेमाल करने की अनुमति दी जाए. |
कमाई करने से जुड़ा पोर्टल | कमाई करने के फ़्लो में एंट्री पॉइंट. पोर्टल, कमाई करने के आपके समाधान के अलग-अलग फ़्लो तय करते हैं. उदाहरण के लिए, एक पोर्टल "कमाई करने" के लिए हो सकता है, जहां उपयोगकर्ता आपकी सेवा की सदस्यता ले सकता है. "साइन इन" के लिए एक और पोर्टल हो सकता है. यहां उपयोगकर्ता, किसी मौजूदा सदस्यता को ऐक्सेस करने के लिए साइन इन कर सकता है. |
रजिस्ट्रेशन कुंजी | कमाई करने की सुविधा देने वाली कंपनी का आइडेंटिफ़ायर. इसका इस्तेमाल, पेज लोड होने के समय, Google की निजता और मैसेज सेवा के साथ, आपकी कंपनी के लागू किए गए टूल को रजिस्टर करने के लिए किया जाता है. |
एपीआई लागू करने का सैंपल
यहां काम करने वाले लागू करने का एक उदाहरण दिया गया है, जो कमाई करने की सुविधा देने वाली कंपनी की जानकारी देता है, उसे इंस्टैंशिएट करता है, और उसे Google की निजता और मैसेज सेवा के साथ रजिस्टर करता है.
<script>
// This class defines a monetization provider by implementing four core functions that every provider
// must support: initialize, getUserEntitlementState, monetize, and destroy.
class CustomMonetizationProvider {
userEntitlementState;
async initialize(initializeParams) {
// Replace this function's code with your implementation of the initialize function.
this.userEntitlementState = googlefc.monetization.UserEntitlementStateEnum.ENTITLED_NO;
return {initializeSuccess: true, apiVersionInUse: "1.0.0", signInMonetizationPortalSupported: false};
}
async getUserEntitlementState() {
// Replace this function's code with your implementation of the getUserEntitlementState function.
return this.userEntitlementState;
}
async monetize(monetizeParams) {
// Replace this function's code with your implementation of the monetize function.
if (monetizeParams.monetizationPortal == googlefc.monetization.MonetizationPortalEnum.PORTAL_PRIMARY_ACCESS) {
return await this.showSubscriptionPrompt();
} else {
console.log('Unsupported monetization portal.');
}
}
async destroy(destructionParams) {
// Replace this function's code with your implementation of the destroy function.
console.log('Custom provider is no longer initialized.');
}
// ==== The helper functions in this section are only used for this demo, and should be omitted from your actual implementation. ===
async showSubscriptionPrompt() {
return new Promise(resolve => {
const sharedStyles = 'border: 2px solid #6b6e7666; border-radius: 8px; padding: 10px; background: white;';
const modalStyles = 'width: 500px; z-index: 100; top: 50%; left: 50%; position: absolute; transform: translate(-50%, -50%);';
const overlayStyles = 'height: 100%; width: 100%; background: black; opacity: 0.6; z-index: 99; position: absolute; top: 0;';
const modal = this.createElement("div", modalStyles + sharedStyles);
const overlay = this.createElement("div", overlayStyles);
const header = this.createElement("h1", 'text-align: center; color: black;', "Subscribe for access.");
const subscribeButton = this.createElement("button", sharedStyles + 'color: #5499C7; margin-left: 40%;', "Subscribe");
const backButton = this.createElement("button", sharedStyles + 'color: #5499C7;', "Back");
this.exitSubscriptionPromptOnButtonClick(subscribeButton, resolve, googlefc.monetization.UserEntitlementStateEnum.ENTITLED_YES, modal, overlay);
this.exitSubscriptionPromptOnButtonClick(backButton, resolve, googlefc.monetization.UserEntitlementStateEnum.ENTITLED_NO,modal, overlay);
modal.append(backButton, header, subscribeButton);
document.body.append(overlay, modal);
});
}
createElement(tag, styles = '', textContent ='') {
const element = document.createElement(tag);
element.style.cssText = styles;
element.textContent = textContent;
return element;
}
exitSubscriptionPromptOnButtonClick(button, resolve, userEntitlementStateEnum, modal, overlay) {
button.addEventListener("click", () => {
document.body.removeChild(modal);
document.body.removeChild(overlay);
this.userEntitlementState = userEntitlementStateEnum;
resolve({userEntitlementState: userEntitlementStateEnum});
});
}
// =============================================================================================================================
};
// Important: code to register a custom monetization provider with Google Privacy & messaging.
window.googlefc = window.googlefc || {};
window.googlefc.monetization = window.googlefc.monetization || {};
window.googlefc.monetization.providerRegistry =
window.googlefc.monetization.providerRegistry || new Map();
window.googlefc.monetization.providerRegistry.set(
'publisherCustom', new CustomMonetizationProvider());
</script>
ऊपर दिया गया कोड स्निपेट, स्केलेटन लागू करने का तरीका है. इसमें, कमाई करने की सुविधा देने वाली कंपनी को निजता और मैसेज सेवा के साथ इंटिग्रेट करने के लिए ज़रूरी सभी चीज़ें शामिल हैं. ध्यान दें कि हर प्रोवाइडर फ़ंक्शन के लिए, उदाहरण के तौर पर कोड जोड़ा गया है. इसे अपने हिसाब से लागू करने की ज़िम्मेदारी आपकी है.
तरीके के बारे में खास जानकारी
कमाई करने की सुविधा देने वाली कंपनी एक ऐसा ऑब्जेक्ट है जो फ़ंक्शन के मुख्य सेट को एक्सपोज़ करके, वेब पेजों पर कमाई करने की सुविधा देता है. इन फ़ंक्शन के बारे में यहां ज़्यादा जानकारी दी गई है.
तरीका | खास जानकारी |
---|---|
initialize | कमाई करने की सुविधा देने वाली कंपनी को शुरू करें. साथ ही, कमाई करने से जुड़ी कार्रवाइयां करने के लिए ज़रूरी सभी संसाधनों को भी शुरू करें. |
getUserEntitlementState | कॉल करने के समय, उपयोगकर्ता के एनटाइटलमेंट की स्थिति देखें. |
कमाई करना | वेब पेज पर, कमाई करने के अपने कस्टम तरीके को रेंडर करें. कमाई करने का आपका तरीका, किसी भी तरह का हो सकता है. जैसे, इनाम वाला विज्ञापन, सदस्यता सेवा डायलॉग वगैरह. |
नष्ट करना | शुरू करने पर चल रहे सभी संसाधनों या जॉब के साथ-साथ, प्रोवाइडर को भी मिटा दें. ऑफ़रवॉल को हटाने के बाद, वह अब किसी भी सेवा देने वाली कंपनी के तरीकों को ट्रिगर नहीं करता. |
तरीके की परिभाषाएं
कमाई करने के हर तरीके के बारे में यहां बताया गया है.
शुरू करना
initialize(initializeParams:InitializeParams): Promise<InitializeResponse>
कमाई करने की सुविधा देने वाली कंपनी को शुरू करें. शुरू होने के बाद, सेवा देने वाली कंपनी या डिपार्टमेंट, सेवा देने से जुड़े किसी भी अन्य फ़ंक्शन का जवाब देने के लिए तैयार होनी चाहिए. यह पक्का है कि यह फ़ंक्शन, सेवा देने वाली किसी भी अन्य कंपनी के फ़ंक्शन से पहले शुरू होगा. साथ ही, किसी पेज लोड होने पर यह फ़ंक्शन ज़्यादा से ज़्यादा एक बार शुरू होगा.
उदाहरण:
async initialize(initializeParams: InitializeParams): Promise<InitializeResponse> {
const isInitializationSuccessful = await this.initializeMyProvider(initializeParams);
const initializeResponse = {initializeSuccess: isInitializationSuccessful,
apiVersionInUse: "1.0.0",
signInMonetizationPortalSupported: true};
resolve(initializeResponse);
}
getUserEntitlementState
getUserEntitlementState(): Promise<UserEntitlementStateEnum>
कॉल करने के समय, उपयोगकर्ता के एनटाइटलमेंट की स्थिति देखें. अगर उपयोगकर्ता के पास एनटाइटलमेंट है, तो Offerwall मैसेज नहीं दिखता. ऐसा इसलिए, क्योंकि उपयोगकर्ता को वेबसाइट का ऐक्सेस बिना किसी शुल्क के मिलना चाहिए.
उदाहरण:
async getUserEntitlementState(): Promise<googlefc.monetization.UserEntitlementStateEnum> {
resolve(this.isUserLoggedIn() ? this.isUserEntitledOnThisPage()
: googlefc.monetization.UserEntitlementStateEnum.ENTITLED_NO);
}
कमाई करना
monetize(monetizeParams:MonetizeParams): Promise<MonetizeResponse>
कमाई करने का अपना सलूशन रेंडर करें और उपयोगकर्ता की कमाई करने से जुड़ी कार्रवाइयों को मैनेज करें. कमाई करने के लिए, इनमें से किसी भी तरीके का इस्तेमाल किया जा सकता है. जैसे, इन-ऐप्लिकेशन खरीदारी, सदस्यता वाली सेवा वगैरह. Offerwall के ज़रिए इस तरीके का इस्तेमाल करने के बाद, जब तक वादा पूरा नहीं हो जाता, तब तक Offerwall नहीं दिखता. इसलिए, पेज के कॉन्टेंट को तब तक गेट करने की ज़िम्मेदारी, सेवा देने वाली कंपनी की होती है, जब तक कि समस्या हल नहीं हो जाती. वादा पूरा होने के बाद, सेवा देने वाली कंपनी को यह भी पक्का करना होगा कि वह अब वेब पेज पर न दिखे.
हमारा सुझाव है कि कमाई करने के अपने तरीके में, InitializeParams में दिए गए सुझाए गए भाषा कोड और स्टाइल का इस्तेमाल करें. इससे, ऑफ़रवॉल और सेवा देने वाली कंपनी के बीच, विज़ुअल के मामले में बेहतर अनुभव मिलता है.
Offerwall, कमाई करने के पोर्टल पैरामीटर को सेट करता है, ताकि यह पता चल सके कि उसे कौनसा पोर्टल ऐक्सेस करना है. पोर्टल के दो टाइप उपलब्ध हैं. पहला PORTAL_PRIMARY_ACCESS
, जो ज़रूरी है और दूसरा PORTAL_SIGN_IN
, जो ज़रूरी नहीं है. initialize फ़ंक्शन के लिए दिए गए जवाब में यह बताया जा सकता है कि आपके पास वैकल्पिक पोर्टल PORTAL_SIGN_IN
के साथ काम करने की सुविधा है या नहीं.
कमाई करने की सुविधा से जुड़े वादे को पूरा करने के बाद, आपको ये काम करने होंगे:
कमाई करने के लिए रेंडर किया गया समाधान छिपाएं.
यह बताएं कि उपयोगकर्ता के पास पेज के कॉन्टेंट का एनटाइटलमेंट है या नहीं. इससे यह तय होता है कि Offerwall दिखता रहेगा या छिपा दिया जाएगा.
अगर लागू हो, तो उपयोगकर्ता इंटरैक्शन से जुड़ा कोई अन्य डेटा दिखाएं. जैसे, चुकाई गई रकम, एनटाइटलमेंट का टाइप और वैल्यू, और कमाई करने की बारंबारता.
उदाहरण:
async monetize(monetizeParams: MonetizeParams): Promise<MonetizeResponse> {
const result;
if (monetizeParams.monetizationPortal == googlefc.monetization.MonetizationPortalEnum.PORTAL_PRIMARY_ACCESS) {
result = await this.showMyBuyFlow();
} else if (monetizeParams.monetizationPortal == googlefc.monetization.MonetizationPortalEnum.PORTAL_SIGN_IN) {
result = await this.showMySignInFlow();
}
if (!result.monetized) {
resolve({userEntitlementState: googlefc.monetization.UserEntitlementStateEnum.ENTITLED_NO});
}
const monetizeResponse = {
userEntitlementState: googlefc.monetization.UserEntitlementStateEnum.ENTITLED_YES,
newlyGrantedUserEntitlementType: googlefc.monetization.EntitlementTypeEnum.TYPE_PAGEVIEW_COUNT,
newlyGrantedUserEntitlementValue: 4,
newlyPaidAmountByUser: {currencyCode: "USD", units: 5, nanos: 0},
// This monetization event does not auto-recur, so leaving property
// recurrenceOfNewMonetizationEvent undefined.
}
resolve(monetizeResponse);
}
बंद करें
destroy(destroyParams:DestroyParams): void
प्रोवाइडर को नष्ट करें. यह पक्का है कि इस फ़ंक्शन को प्रोवाइडर के लाइफ़साइकल में आखिर में कॉल किया जाएगा. साथ ही, आपको यह उम्मीद करनी चाहिए कि किसी पेज लोड पर इसे ज़्यादा से ज़्यादा एक बार कॉल किया जाएगा.
उदाहरण:
destroy(destroyParams: DestroyParams): void {
this.recordDestroyReason(destroyParams.destroyReason);
this.destroyAllOfMyResourcesOnPage();
}
प्रकार की परिभाषाएं
एपीआई में डेटा के हर टाइप की परिभाषा नीचे दी गई है.
ऑब्जेक्ट की परिभाषाएं
इस सेक्शन में, एपीआई में मौजूद सभी ऑब्जेक्ट की परिभाषाएं दी गई हैं.
InitializeParams
initialize फ़ंक्शन के लिए पैरामीटर का टाइप.
interface InitializeParams {
// The loaded monetization provider API version. i.e. "1.0.0"
currentApiVersion: string;
// The language code suggested for the provider to use, as defined by BCP 47.
suggestedLanguageCode?: string;
// The styles suggested for the provider to use.
suggestedStyles?: Styles;
// The publisher's logo url.
publisherLogoUrl?: string;
}
Styles
स्टाइल तय करने का टाइप.
interface Styles {
// The primary color of the Offerwall.
primaryColor?: string;
// The background color of the Offerwall.
backgroundColor?: string;
}
InitializeResponse
initialize फ़ंक्शन के लिए रिस्पॉन्स टाइप.
interface InitializeResponse {
// Whether or not initialization was successful. If initialization is
// unsuccessful, the Offerwall does not proceed to call other provider methods
// except for destroy.
initializeSuccess: boolean;
// The monetization provider API version that the provider is using. If the
// indicated major version is not equal to the major version of the API
// currently on the page, provider execution is halted.
apiVersionInUse: string;
// Whether or not the optional sign-in monetization portal is supported. If
// you indicate that it is supported, the Offerwall renders a sign-in link
// that will invoke your sign-in portal upon user click.
signInMonetizationPortalSupported: boolean;
// Whether or not the provider is disabled. If disabled, the Offerwall can
// only render with other eligible choices; if no other choices are eligible,
// the Offerwall won't ever render on the page.
isProviderDisabled?: boolean;
}
MonetizeParams
कमाई करें फ़ंक्शन के लिए पैरामीटर टाइप.
interface MonetizeParams {
// The monetization portal that the Offerwall wants to invoke. You can
// indicate whether you support any optional portals in your
// InitializeResponse; the only portal that isn't optional is
// MonetizationPortalEnum.PORTAL_PRIMARY_ACCESS. The Offerwall provides the
// portal enum for the flow requested by the user.
monetizationPortal: googlefc.monetization.MonetizationPortalEnum;
}
MonetizeResponse
कमाई करें फ़ंक्शन के लिए रिस्पॉन्स टाइप.
interface MonetizeResponse {
// The user's current entitlement state.
userEntitlementState: googlefc.monetization.UserEntitlementStateEnum;
// The user's granted entitlement type, only populated if an entitlement was
// granted within the scope of the current MonetizationProvider.monetize
// invocation.
newlyGrantedUserEntitlementType?: googlefc.monetization.EntitlementTypeEnum;
// The user's granted entitlement value, only populated if an entitlement was
// granted within the scope of the current MonetizationProvider.monetize
// invocation.
newlyGrantedUserEntitlementValue?: number;
// The amount paid by the user, only populated if a payment occurred within
// the scope of the current MonetizationProvider.monetize invocation.
newlyPaidAmountByUser?: Money;
// The recurrence of the monetization event, populated only if the
// monetization event occurred within the scope of the current
// MonetizationProvider.monetize invocation & the monetization event is
// expected to auto-recur without further action from the user (e.g.
// registering for a monthly subscription)
recurrenceOfNewMonetizationEvent?: googlefc.monetization.MonetizationRecurrenceEnum;
}
Money
किसी खास मुद्रा में रकम तय करने का टाइप. money.proto की मूल परिभाषा देखें.
interface Money {
// The three-letter currency code defined in ISO 4217.
currencyCode: string;
// The whole units of the amount.
// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
units?: number;
// Number of nano (10^-9) units of the amount.
// The value must be between -999,999,999 and +999,999,999 inclusive.
// If `units` is positive, `nanos` must be positive or zero.
// If `units` is zero, `nanos` can be positive, zero, or negative.
// If `units` is negative, `nanos` must be negative or zero.
// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
nanos?: number;
}
DestroyParams
destroy फ़ंक्शन के लिए पैरामीटर का टाइप.
interface DestroyParams {
// The reason for destroying the provider.
destroyReason: googlefc.monetization.DestroyReasonEnum;
}
Enum की परिभाषाएं
इस सेक्शन में, एपीआई में मौजूद सभी एनम की परिभाषाएं दी गई हैं.
googlefc.monetization.UserEntitlementStateEnum
एनटाइटलमेंट की जानकारी से पता चलता है कि उपयोगकर्ता, कमाई करने की सुविधा देने वाली किसी कंपनी के साथ काम कर सकता है.
googlefc.monetization.UserEntitlementStateEnum {
ENTITLED_UNKNOWN = 0,
// The user is currently entitled to access page content.
ENTITLED_YES = 1,
// The user is not currently entitled to access page content.
ENTITLED_NO = 2,
}
googlefc.monetization.MonetizationPortalEnum
कमाई करने के उन अलग-अलग पोर्टल या कमाई करने के एंट्री पॉइंट की जानकारी जिनका इस्तेमाल सेवा देने वाली कंपनी कर सकती है. कमाई करने वाले पोर्टल के बारे में ज़्यादा जानने के लिए, शब्दकोश देखें.
googlefc.monetization.MonetizationPortalEnum {
PORTAL_UNKNOWN = 0,
// The primary access portal represents a provider's main entry point into a
// monetization flow, and must always be supported.
PORTAL_PRIMARY_ACCESS = 1,
// The sign in portal represents a provider's monetization entry point that
// usually begins with the user performing some sign-in or registration
// action. Provider support for this monetization portal type is optional.
PORTAL_SIGN_IN = 2,
}
googlefc.monetization.EntitlementTypeEnum
कमाई करने की सुविधा देने वाली कंपनी, उपयोगकर्ता को अलग-अलग तरह के एनटाइटलमेंट दे सकती है.
googlefc.monetization.EntitlementTypeEnum {
TYPE_UNKNOWN = 0,
// This type is used if the user is awarded a positive integer value of
// Offerwall-free pageviews.
TYPE_PAGEVIEW_COUNT = 1,
// This type is used if the user is awarded a positive integer value of
// seconds (duration) in which they can access Offerwall-free page content any
// number of times.
TYPE_DURATION_SECONDS = 2,
}
googlefc.monetization.DestroyReasonEnum
कमाई करने की सुविधा देने वाली कंपनी को हटाने की वजहें.
googlefc.monetization.DestroyReasonEnum {
REASON_UNKNOWN = 0,
// The Offerwall no longer needs to invoke the monetization provider on the
// pageview.
REASON_CALLER_FINISHED = 1,
// The Offerwall encountered an erroneous state with the monetization provider
// in the midst of the provider's lifecycle.
REASON_ERROR_STATE = 2,
// The API version that the monetization provider is currently using is no
// longer supported.
REASON_UNSUPPORTED_API_VERSION = 3,
}
googlefc.monetization.MonetizationRecurrenceEnum
कमाई करने के लिए, बार-बार होने वाली अलग-अलग कार्रवाइयों की जानकारी, जिन्हें उपयोगकर्ता की किसी कार्रवाई के आधार पर शुरू किया जा सकता है.
googlefc.monetization.MonetizationRecurrenceEnum {
MONETIZATION_RECURRENCE_UNKNOWN = 0,
MONETIZATION_RECURRENCE_WEEKLY = 1,
MONETIZATION_RECURRENCE_MONTHLY = 2,
MONETIZATION_RECURRENCE_ANNUALLY = 3,
}
कंपनी का रजिस्ट्रेशन
googlefc.monetization.providerRegistry?: Map
<string, Object>
कमाई करने की सुविधा देने वाली कंपनियों को रजिस्टर करने के लिए इस्तेमाल किया जाने वाला, विंडो-लेवल का JavaScript ऑब्जेक्ट.
रजिस्ट्रेशन में, स्टैटिक रजिस्ट्रेशन कुंजी से शुरू किए गए प्रोवाइडर ऑब्जेक्ट को, विंडो नेमस्पेस में मौजूद रजिस्ट्री में पास करना शामिल है:
window.googlefc.monetization
// Register a custom monetization provider with Google Privacy & messaging.
window.googlefc = window.googlefc || {};
window.googlefc.monetization = window.googlefc.monetization || {};
window.googlefc.monetization.providerRegistry =
window.googlefc.monetization.providerRegistry || new Map();
window.googlefc.monetization.providerRegistry.set(
'publisherCustom', new CustomMonetizationProvider());
वर्शन इतिहास
वर्शन | रिलीज़ की तारीख | खास जानकारी |
---|---|---|
1.0.0 | 24/07/2023 | कमाई करने की सुविधा देने वाली कंपनी के एपीआई की शुरुआती रिलीज़. |