Skip to content

Unity SDK Integration Guide


Before you Begin

  • You must have an active AdGem account
  • You must add your App to your account
  • The AdGem Unity SDK supports devices Android 5 and higher and iOS 9.0 and higher
  • The AdGem Unity SDK is compatible with apps built in Unity 2018 and higher


Step 1. Import AdGem Unity SDK Package

First, you will need to download the latest AdGem Unity SDK Download v2.0.3

Once you have downloaded the AdGem SDK, open your Unity project, double click AdGemSdk.unitypackage and import all files.

Step 2. Add AdGemPrefab To Your Scenes

Inside the Plugins/AdGemSdk folder, you will find a prefab called AdGemPrefab. Add this to your first scene. It will automatically persist throughout the game.

Step 3. Initialize AdGem SDK

In the first scene of your app, call the following function in the Start() method.

using AdGemUnity;

AdGem.startSession(int, bool, bool, bool)

Parameter Type Description
AppID integer Your AdGem app ID, found in the Adgem Publisher dashboard.
UsesInterstitialVideos boolean Whether or not your app shows interstitial (non-rewarded) videos.
UsesRewardVideos boolean Whether or not your app shows rewarded videos.
UsesOfferWall boolean Whether or not your app shows the offer wall.


       AdGem.startSession(1487, true, true, true);
       AdGem.startSession(1493, true, true, true);

Step 4. Ad Units

Before showing a rewarded-video ad, check if AdGem.rewardVideoReady is true. If so, you can start an ad by calling:


Before showing a interstitial ad, check if AdGem.interstitialVideoReady is true. If so, you can start an ad by calling:


Before showing the offer wall, check if AdGem.offerWallReady is true. If so, you can show the offer wall by calling:


Step 5. Delegate Methods

For being alerted when a reward video is ready, use:

AdGem.rewardVideoDownloadCompleted = () => {
   // Your code here

For being alerted when a interstitial video is ready, use:

AdGem.interstitialVideoDownloadCompleted = () => {
    // Your code here

For being alerted when a video ad actually starts playing, use:

AdGem.videoAdStarted = () => {
    // Your code here

To be alerted when a user successfully completes an offer on the offer wall, use:

AdGem.offerWallRewardReceived = i => {
    // Your code here using the int i
For the Offer Wall, the delegate is of type Action<int>, with the integer value being the amount of in-game virtual currency received from the offer.

Full list of the delegate methods available to use:

public static Action rewardVideoDownloadCompleted;
public static Action rewardVideoFinishedPlaying;
public static Action rewardVideoCanceled;
public static Action interstitialVideoDownloadCompleted;
public static Action interstitialVideoFinishedPlaying;
public static Action interstitialVideoCanceled;
public static Action videoFailedToLoad;
public static Action adClicked;
public static Action<int> offerWallRewardReceived;

Step 6. Set the player id (for non games, the unique identifier for a user)

For increased fraud protection, we highly recommend you set the player_id (a unique id for your user) parameter.

AdGem.player_id = "player123";
AdGem.player_age = 18;
AdGem.player_gender = AdGem.Gender.Female;
AdGem.player_payer = false;
AdGem.player_iap_total_usd = 0;
AdGem.player_created_at = "date value";
AdGem.player_level = 7;
AdGem.placement = 2;
AdGem.c1 = "your custom value 1";
AdGem.c2 = "your custom value 2";
AdGem.c3 = "your custom value 3";
AdGem.c4 = "your custom value 4";
AdGem.c5 = "your custom value 5";

Important Notes

  • If boolean AdGem.videoIsPlaying is true, it is important to suppress user input until the video-finished-playing Action is raised.
  • When you build for iOS, you must include the StoreKit.framework in your XCode project within the build phases tab.
  • It appears that Unity has an issue that will crash an Android app if a new scene tries to load at the same instant that an Intent opens another app (such as a browser). It is recommended that you do not put any scene loading commands in the video complete delegate functions.
  • If your app was built in Unity 2017 and your receiving the error “Unable to instantiate prefab”, you’ll need to make a slight adjustment to the AdGem Unity plugin within the text editor. Adjust the AdGemPrefab.prefab in the text editor: from m_SourcePrefab to m_ParentPrefab from m_IsPrefabAsset to m_IsPrefabParent.
  • If you have an Android manifest file in your assets/plugins/android folder, make sure not to import the android manifest in the adgem package. Instead, add the following code inside the application block of your existing manifest:

Otherwise, if you do not already have a manifest, go ahead and import the manifest from the adgem package.

Optional Parameters

You can optimize your revenue potential by segmenting your users using the optional parameters available in the Unity SDK. Please visit Optional Parameters to learn more.

Additional Options

You can optionally pre-load the Offer Wall before showing it to the user by using loadOfferWallBeforeShowing.

AdGem.loadOfferWallBeforeShowing = true;

You can enable verbose logging by setting verboseLogging to true. By default, verbose logging is disable.

AdGem.verboseLogging = true;

Postback Setup

If you have opted for a “Server Postback”, on each successful offer completion by a user AdGem will send a GET request to your server. Please visit our guide on Server Postback Setup to learn more.

Back to top