인스턴트 게임의 앱 내 광고

게이머에게 광고를 표시해서 게임을 수익화할 수 있습니다. 현재 인스턴트 게임에는 두 가지 형식의 Audience Network 광고(보상형 동영상 광고 및 전면 광고)가 있습니다. 이 섹션에서는 인스턴트 게임으로 광고 수익화를 통합하는 과정을 설명합니다.

형식 가용성

플랫폼전면 광고보상형 전면 광고보상형 동영상 광고

Android

iOS

모바일 웹

데스크톱 웹

필수 조건

  • 수익 관리자에서 게임과 연결된 자산 내에 광고 노출 위치를 1개 이상 생성해야 합니다.
  • 모바일 기기나 Facebook.com에서 빌드를 테스트할 수 있습니다.

참고: 현재 Audience Network는 일부 지역에서 제한됩니다. Audience Network 온보딩 플로에서 자격 요건을 확인하세요.

자세한 내용은 인스턴트 게임 수익화를 위한 Audience Network 5단계 가이드를 참조하세요.

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);
});

광고 인스턴스의 수명 주기

같은 유형의 광고 인스턴스 세 개를 표시하지 않고 사전 로드하면 새 광고를 생성하려고 시도할 때 실패합니다. 광고를 성공적으로 읽어들이면 광고는 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 인사이트도 참조하세요.

광고 시간을 적절히 맞추세요. 게임 내 광고가 게이머의 경험을 방해하지 않도록 하세요.

광고를 사전 로드하세요. 광고를 요청하고 사전 로드하고 동시에 표시하기 위해 마지막 순간까지 기다리지 마세요. 대신 일부 AdInstances를 사전 로드하여 게이머가 광고를 표시해달라고 요청했을 때 오래 기다릴 필요가 없도록 하세요.

지원을 확인하세요. 게이머의 세션이 광고를 지원하지 않는 경우도 있습니다(예: 데스크톱 브라우저에서 플레이하는 경우). 광고를 요청하기 전에 항상 광고가 FBInstant.getSupportedAPIs()로 지원되는지 확인해야 합니다.

'광고를 채우지 않는 경우(No fills)'의 처리를 적절히 구현하세요. 일부 조건으로 인해 광고가 채워지지 않을 수 있습니다. 이 경우 프로미스가 ADS_NO_FILL 오류 메시지와 함께 거부됩니다. 게임에서 이 오류를 적절히 처리하고 친근한 메시지를 표시한 다음, 30초 동안 기다렸다가 같은 유형의 다른 광고를 요청해야 합니다.

제출 전에 광고를 테스트하세요. Audience Network 검수를 위해 앱을 제출하기 전이라도 앱 개발자는 모바일에서 광고를 요청하고 통합이 작동하는지 확인할 수 있습니다.

광고 노출을 추적하세요. 맞춤 이벤트를 사용하여 showAsync 분석 시 광고 노출 위치를 추적할 수 있습니다.

너무 많은 AdInstances를 유지하지 마세요. getRewardedVideoAsync 또는 getInterstitialAdAsync 메서드는 사전 로드가 가능한 AdInstance를 반환합니다. 같은 유형의 AdInstances 3개 이상을 표시하지 않고 사전 로드하면 나중에 새 AdInstance를 생성하려고 시도할 때 실패합니다. 즉, getRewardedVideoAsyncgetInterstitialAdAsyncshowAsync를 호출하거나 게이머가 Messenger를 다시 시작할 때까지 오류 코드 ADS_TOO_MANY_INSTANCES와 함께 실패합니다.