Monetizing your game with Facebook rewarded ads Unity is a great way to offer players in-game rewards while also generating revenue. Rewarded ads allow users to voluntarily watch an ad in exchange for valuable in-game rewards, such as extra lives or coins. This non-intrusive method of monetization can improve user engagement and retention, making it an excellent choice for many developers. In this guide, we’ll walk you through the process of integrating Facebook’s Audience Network into your Unity game.
Unity Facebook Ads Tutorial
In this Unity Facebook Ads Tutorial, the first step is to create a Facebook developer account and register your game on the Facebook platform. After registering, you’ll need to create a placement ID for your rewarded ads. This unique ID links your Unity project to Facebook’s Audience Network, enabling you to display rewarded ads within your game.
Next, download and import the Facebook Audience Network SDK into your Unity project. The SDK provides all the necessary tools to display ads and track their performance. Once the SDK is integrated, initialize it with the provided app ID, and configure it to load rewarded video ads using the placement ID you created earlier.
Now that your setup is complete, it’s time to integrate the actual logic for displaying Audience Network rewarded ads in Unity game. Rewarded ads should be shown at moments where users can benefit from extra rewards—such as after completing a level or reaching a milestone. Be sure to check if the ad is available before attempting to display it to avoid errors.
Unity Audience Network Integration
Effective Unity audience network integration involves more than just technical setup. It’s important to ensure that your rewarded ads are displayed at the right moments to maximize player engagement. For example, offering rewards for watching ads after a level or a game over can incentivize users without interrupting the flow of gameplay.
Additionally, it’s crucial to handle the ad lifecycle correctly—preloading the ads ahead of time and making sure players receive their rewards only after fully watching the ad. Facebook provides test IDs so you can verify your integration without showing real ads during development.
In this second part of the Unity Facebook Ads Tutorial, it’s essential to track the performance of your rewarded ads and optimize them for better results. Facebook’s Audience Network provides analytics that help you understand how users are interacting with your ads, allowing you to fine-tune ad placements and strategies to maximize revenue.
Conclusion
In conclusion, by following this Facebook rewarded ads Unity tutorial, you can effectively implement a monetization strategy that benefits both you and your players. By offering rewards in exchange for ad views, you can create a sustainable revenue stream while enhancing the player experience.
Script: FacebookRewarded.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AudienceNetwork;
public class FacebookRewarded : MonoBehaviour
{
public string rewardedID = "";
private bool isLoaded;
private RewardedVideoAd rewardedVideoAd;
// Start is called before the first frame update
void Start()
{
LoadRewardedVideo();
}
public void LoadRewardedVideo()
{
// Create the rewarded video unit with a placement ID (generate your own on the Facebook app settings).
// Use different ID for each ad placement in your app.
this.rewardedVideoAd = new RewardedVideoAd(rewardedID);
this.rewardedVideoAd.Register(this.gameObject);
// Set delegates to get notified on changes or when the user interacts with the ad.
this.rewardedVideoAd.RewardedVideoAdDidLoad = (delegate () {
Debug.Log("RewardedVideo ad loaded.");
this.isLoaded = true;
});
this.rewardedVideoAd.RewardedVideoAdDidFailWithError = (delegate (string error) {
Debug.Log("RewardedVideo ad failed to load with error: " + error);
LoadRewardedVideo();
});
this.rewardedVideoAd.RewardedVideoAdWillLogImpression = (delegate () {
Debug.Log("RewardedVideo ad logged impression.");
});
this.rewardedVideoAd.RewardedVideoAdDidClick = (delegate () {
Debug.Log("RewardedVideo ad clicked.");
});
this.rewardedVideoAd.RewardedVideoAdDidClose = (delegate () {
Debug.Log("Rewarded video ad did close.");
if (this.rewardedVideoAd != null)
{
this.rewardedVideoAd.Dispose();
}
LoadRewardedVideo();
});
this.rewardedVideoAd.RewardedVideoAdDidSucceed = (delegate () {
Debug.Log("Rewarded video ad validated by server");
//HERE GOES THE REWARD
});
this.rewardedVideoAd.RewardedVideoAdDidFail = (delegate () {
Debug.Log("Rewarded video ad not validated, or no response from server");
});
// Initiate the request to load the ad.
this.rewardedVideoAd.LoadAd();
}
public void ShowRewardedVideo()
{
if (this.isLoaded)
{
this.rewardedVideoAd.Show();
this.isLoaded = false;
}
else
{
Debug.Log("Ad not loaded. Click load to request an ad.");
}
}
}
Download Unity Facebook Ads SDK From Here
Integration Guide From Here
Test Ad IDs From Here
Using rewarded ads is a great way to boost engagement and revenue in your Unity game. While Facebook Audience Network offers solid options for rewarded ads, integrating multiple ad networks can help increase fill rates and overall earnings. If you want to add AdMob to your project, check out this Unity AdMob Rewarded Ads Tutorial for a step-by-step guide on implementing this popular ad format alongside Facebook rewarded ads.
