คุณสามารถสร้างรายได้จากเกมของคุณโดยการแสดงโฆษณาให้กับผู้เล่นได้ โดยในปัจจุบัน โฆษณา Audience Network ที่ผสานรวมเข้ากับเกมทันใจมีอยู่ 2 รูปแบบ ได้แก่ วิดีโอที่มีรางวัลหลังชมจบและโฆษณาคั่น ส่วนนี้จะให้คำแนะนำแก่คุณตลอดกระบวนการผสานรวมการสร้างรายได้จากโฆษณาเข้ากับเกมทันใจของคุณ
แพลตฟอร์ม | โฆษณาคั่น | โฆษณาคั่นที่มีรางวัลหลังชมจบ | วิดีโอที่มีรางวัลหลังชมจบ |
---|---|---|---|
Android | ✅ | ✅ | ✅ |
iOS | ✅ | ✅ | ✅ |
เว็บบนมือถือ | ✅ | ✅ | ✅ |
เว็บบนเดสก์ท็อป | ✅ | ✅ | ✅ |
หมายเหตุ: ปัจจุบัน Audience Network มีการจำกัดในบางภูมิภาค โปรดตรวจสอบสิทธิ์การใช้งานของคุณในขั้นตอนการเริ่มต้นใช้งาน Audience Network
โปรดดูข้อมูลเพิ่มเติมที่คู่มือ 5 ขั้นตอนในการสร้างรายได้จากเกมทันใจด้วย Audience Network
กำหนดค่าแอพ Facebookหากคุณกำหนดค่าแอพของคุณกับตัวจัดการการสร้างรายได้และสร้างตำแหน่งการจัดวางโฆษณาแล้ว คุณจะสามารถดูการใช้งานโค้ดตัวอย่างได้ที่ด้านล่างโดยการดาวน์โหลดตัวอย่างของเรา:
ดาวน์โหลดตัวอย่างโฆษณา (.zip)โฆษณาคั่นคือโฆษณาแบบเต็มหน้าจอที่ปรากฏขึ้นขณะเปลี่ยนจากจุดหนึ่งไปอีกจุดหนึ่งตามปกติในแอพของคุณ โฆษณาคั่นจะเป็นแบบเล่นอัตโนมัติหรือคลิกเพื่อเล่นก็ได้ โฆษณาแบบเล่นอัตโนมัติจะเริ่มเล่นในทันทีที่มีการโหลดโฆษณาคั่น ซึ่งตามค่าเริ่มต้นแล้ว ผู้ชมจะสามารถกดข้ามได้หลังจากเล่นไปแล้ว 3 วินาที โดยโฆษณาประเภทนี้จะมีความยาวสูงสุดได้ไม่เกิน 2 นาที
ส่วนย่อยของโค้ดด้านล่างแสดงตัวอย่างวิธีแสดงโฆษณาคั่น
หากต้องการให้โค้ดนี้ใช้งานได้ ก่อนอื่นคุณจะต้องสร้างตำแหน่งการจัดวางโฆษณาโดยใช้รูปแบบการแสดงผลแบบโฆษณาคั่น คุณควรใช้ตำแหน่งการจัดวางที่ต่างกันสำหรับหน่วยโฆษณาแต่ละหน่วยในแอพของคุณ
var preloadedInterstitial = null; FBInstant.getInterstitialAdAsync( '123123123123_123123123123' // Your Ad Placement Id ).then(function(interstitial) { // Load the Ad asynchronously preloadedInterstitial = interstitial; return preloadedInterstitial.loadAsync(); }).then(function() { console.log('Interstitial preloaded'); }).catch(function(err){ console.error('Interstitial failed to preload: ' + err.message); });
preloadedInterstitial.showAsync() .then(function() { // Perform post-ad success operation console.log('Interstitial ad finished successfully'); }) .catch(function(e) { console.error(e.message); });
โฆษณาคั่นที่มีรางวัลหลังชมจบคือโฆษณาแบบเต็มหน้าจอ ซึ่งจะมอบสิ่งจูงใจให้กับผู้ใช้โดยแลกเปลี่ยนกับการรับชมโฆษณา โฆษณาเหล่านี้ไม่จำเป็นต้องเสนอให้ลูกค้าเลือกรับ
ส่วนย่อยของโค้ดด้านล่างแสดงตัวอย่างวิธีแสดงโฆษณาคั่นที่มีรางวัลหลังชมจบ
หากต้องการให้โค้ดนี้ใช้งานได้ ก่อนอื่นคุณจะต้องสร้างตำแหน่งการจัดวางโฆษณาโดยใช้รูปแบบการแสดงผลแบบโฆษณาคั่นที่มีรางวัลหลังชมจบ โฆษณาคั่นที่มีรางวัลหลังชมจบใช้งานได้กับแอพใน Facebook Gaming, เว็บบนมือถือ และเว็บบนเดสก์ท็อป คุณควรใช้ตำแหน่งการจัดวางที่ต่างกันสำหรับหน่วยโฆษณาแต่ละหน่วยในแอพของคุณ
var preloadedRewardedInterstitial = null; FBInstant.getRewardedInterstitialAsync( '123123123123_123123123123' // Your Ad Placement Id ).then(function(rewarded) { // Load the Ad asynchronously preloadedRewardedInterstitial = rewarded; return preloadedRewardedInterstitial.loadAsync(); }).then(function() { console.log('Rewarded interstitial preloaded'); }).catch(function(err){ console.error('Rewarded interstitial failed to preload: ' + err.message); });
preloadedRewardedInterstitial.showAsync() .then(function() { // Perform post-ad success operation console.log('Rewarded interstitial watched successfully'); }) .catch(function(e) { console.error(e.message); });
โฆษณาแบบวิดีโอที่มีรางวัลหลังชมจบเป็นแสดงขึ้นแบบเต็มหน้าจอในกรณีที่ผู้ใช้เลือกที่จะรับชมโฆษณาแบบวิดีโอเพื่อแลกกับสิ่งตอบแทนต่างๆ เช่น สกุลเงินเสมือนจริง ไอเท็มในแอพ หรือเนื้อหาสำหรับสมาชิกโดยเฉพาะ
ส่วนย่อยของโค้ดด้านล่างแสดงตัวอย่างวิธีแสดงโฆษณาแบบวิดีโอที่มีรางวัลหลังชมจบ
หากต้องการให้โค้ดนี้ใช้งานได้ ก่อนอื่นคุณจะต้องสร้างตำแหน่งการจัดวางโฆษณาโดยใช้รูปแบบการแสดงผลแบบวิดีโอที่มีรางวัลหลังชมจบ คุณควรใช้ตำแหน่งการจัดวางที่ต่างกันสำหรับหน่วยโฆษณาแต่ละหน่วยในแอพของคุณ
var preloadedRewardedVideo = null; FBInstant.getRewardedVideoAsync( '456456456456_456456456456' // Your Ad Placement Id ).then(function(rewarded) { // Load the Ad asynchronously preloadedRewardedVideo = rewarded; return preloadedRewardedVideo.loadAsync(); }).then(function() { console.log('Rewarded video preloaded'); }).catch(function(err){ console.error('Rewarded video failed to preload: ' + err.message); });
preloadedRewardedVideo.showAsync() .then(function() { // Perform post-ad success operation console.log('Rewarded video watched successfully'); }) .catch(function(e) { console.error(e.message); });
การโหลดอินสแตนซ์โฆษณาล่วงหน้า 3 รายการโดยไม่แสดงอินสแตนซ์ดังกล่าวจะทำให้เกิดความล้มเหลวขึ้นขณะที่คุณพยายามสร้างโฆษณาชิ้นใหม่ เมื่อโหลดโฆษณาสำเร็จแล้ว โฆษณาดังกล่าวจะใช้งานได้เป็นเวลา 60 นาที
นี่คือตัวอย่างโค้ดที่จะช่วยให้คุณเข้าใจวิธีการทำงาน โดยตัวอย่างนี้จะถือว่าคุณได้กำหนดค่าทุกสิ่งไว้อย่างเหมาะสมแล้ว (ID ตำแหน่งการจัดวางโฆษณาที่ถูกต้อง และอื่นๆ) และไม่มีปัญหาเกี่ยวกับเครือข่าย:
var preloadedInterstitial1 = null; var preloadedInterstitial2 = null; var preloadedInterstitial3 = null; var preloadedRewardedVideo = null; // PRELOAD PHASE FBInstant.getInterstitialAdAsync( '123123123123_123123123123' ).then(function(interstitial) { // This should get called, meaning you now have 1 ad instance. preloadedInterstitial1 = interstitial; return preloadedInterstitial1.loadAsync(); }).then(function() { // This should get called unless we do not have ads to serve. console.log('Interstitial 1 preloaded') }).catch(function(err){ // This would be called only if we do not have ads to serve. // The error would then be ADS_NO_FILL. // You can try to reload the ad after some time (ideally over 30 seconds). // If you get ADS_NO_FILL 3 times in a row, the instance will be disabled. console.error('Interstitial 1 failed to preload: ' + err.message); // You can try to reload after 30 seconds (2nd attempt) setTimeout(function () { handleAdsNoFill(preloadedInterstitial1, 2); }, 30 * 1000); }); // Here is how the function to handle ADS_NO_FILL would look like function handleAdsNoFill (adInstance, attemptNumber) { if (attemptNumber > 3) { // You can assume we will not have to serve in the current session, no need to try // to load another ad. return; } else { adInstance.loadAsync().then(function() { // This should get called if we finally have ads to serve. console.log('Interstitial preloaded') }).catch(function(err){ console.error('Interstitial failed to preload: ' + err.message); // You can try to reload after 30 seconds setTimeout(function () { handleAdsNoFill(adInstance, attemptNumber+1); }, 30 * 1000); }); } } // As we covered ADS_NO_FILL, from now on let's assume we have ads to serve. FBInstant.getInterstitialAdAsync( // You can re-use the same Ad Placement Id as long as it is of the valid type: // interstitial or rewarded video (here, it has to be interstitial) '123123123123_123123123123' ).then(function(interstitial) { // This should get called, meaning you now have 2 ad instances. preloadedInterstitial2 = interstitial; return preloadedInterstitial2.loadAsync(); }).then(function() { console.log('Interstitial 2 preloaded') }); FBInstant.getRewardedVideoAsync( '456456456456_456456456456' ).then(function(rewarded) { // This should get called, meaning you now have 3 ad instances. preloadedRewardedVideo = rewarded; return preloadedRewardedVideo.loadAsync(); }).then(function() { console.log('Rewarded video preloaded') }); FBInstant.getInterstitialAdAsync( '123123123123_123123123123' ).catch(function(err){ // This should be called now because you already have 3 ad instances. // The error would then be ADS_TOO_MANY_INSTANCES. console.error('Interstitial 3 failed to preload: ' + err.message); }); // SHOWING ADS (at a timing that makes sense in the workflow of your game) preloadedInterstitial1.showAsync() .then(function() { // This should get called, meaning you now have 2 ad instances. console.log('Interstitial ad 1 finished successfully'); }); // A bit later, assuming you did not preload a new instance yet. preloadedInterstitial2.showAsync() .then(function() { // This should get called, meaning you now have 1 ad instance. console.log('Interstitial ad finished successfully'); }); // A bit later, assuming you did not preload a new instance yet. preloadedRewardedVideo.showAsync() .then(function() { // This should get called, meaning you now have no ad instance. console.log('Rewarded video watched successfully'); });
ข้อมูลด้านล่างมีไว้สำหรับเกมทันใจเท่านั้น โปรดดูที่ข้อมูลเชิงลึกเกี่ยวกับ Audience Network ของเราด้วย
ตั้งเวลาในการโฆษณาให้เหมาะสม ตรวจสอบให้แน่ใจว่าโฆษณาของคุณไม่รบกวนประสบการณ์ของผู้เล่น
โหลดโฆษณาล่วงหน้า อย่ารอจนถึงนาทีสุดท้ายเพื่อร้องขอ โหลดล่วงหน้า และแสดงโฆษณาพร้อมกัน แต่ให้ตรวจสอบให้แน่ใจว่าคุณได้โหลด AdInstance บางส่วนไว้ล่วงหน้าแล้ว เพราะเมื่อผู้เล่นร้องขอการดูโฆษณา พวกเขาจะได้ไม่ต้องรอนานเกินไป
ตรวจสอบการสนับสนุน ในบางกรณี เซสชั่นของผู้เล่นจะไม่สนับสนุนโฆษณา (เช่น หากกำลังเล่นบนเบราว์เซอร์ของเดสก์ท็อป) คุณควรตรวจสอบอยู่เสมอว่าโฆษณาได้รับการสนับสนุนด้วย FBInstant.getSupportedAPIs()
หรือไม่ก่อนที่จะพยายามส่งคำขอโฆษณา
จัดการกับปัญหา "ไม่มีการส่งโฆษณา" อย่างเหมาะสม สภาวะบางอย่างอาจส่งผลให้ไม่มีการส่งโฆษณา ในกรณีดังกล่าว พรอมิสจะปฏิเสธพร้อมแสดงข้อความแสดงข้อผิดพลาด ADS_NO_FILL
ตรวจสอบให้แน่ใจว่าเกมของคุณจัดการเรื่องนี้ได้เรียบร้อยดี แสดงข้อความที่เป็นมิตร และรอ 30 วินาทีก่อนจะร้องขอโฆษณาประเภทเดิมอีกโฆษณาหนึ่ง
ทดสอบโฆษณาของคุณก่อนส่ง ในฐานะผู้พัฒนาแอพ คุณสามารถส่งคำขอโฆษณาบนมือถือและดูว่าการผสานการทำงานของคุณใช้งานได้ก่อนที่คุณจะส่งแอพเพื่อเข้ารับการตรวจสอบบน Audience Network
ติดตามอิมเพรสชั่นของโฆษณา คุณสามารถใช้เหตุการณ์ที่กำหนดเองเพื่อติดตามอิมเพรสชั่นของโฆษณาได้ เมื่อ showAsync
เสร็จเรียบร้อย
อย่าใช้ AdInstance หลายรายการเกินไป ทั้งเมธอด getRewardedVideoAsync
หรือ getInterstitialAdAsync
จะส่งคืน AdInstance
ซึ่งสามารถโหลดล่วงหน้าได้ การโหลด AdInstance ประเภทเดียวกันล่วงหน้าตั้งแต่ 3 รายการขึ้นไปโดยไม่แสดง AdInstance จะส่งผลให้ความพยายามในการสร้าง AdInstance ใหม่หลังจากนั้นล้มเหลว ซึ่งหมายความว่าการเรียกใช้ getRewardedVideoAsync
และ getInterstitialAdAsync
จะล้มเหลวโดยมีรหัสข้อผิดพลาดเป็น ADS_TOO_MANY_INSTANCES
จนกว่าจะมีการเรียกใช้ showAsync
หรือจนกว่าผู้เล่นจะรีสตาร์ท Messenger