Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

10-Step Integration Guide for Unity Ads in Unity

Discussion in 'Unity Ads & User Acquisition' started by unity-nikkolai, Jan 29, 2015.

  1. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Getting started with Unity Ads is easy!

    In this guide, we'll use the Unity Ads Helper to initialize Unity Ads and show an ad on load.

    Let's begin:
    1. Create a new project in Unity.
    2. From Edit > Build Settings, switch the platform to either iOS or Android
    3. To use test mode, enable the Development Build option in Build Settings as well.
    4. Import the Unity Ads asset package from the Asset Store.
    5. Download and import the Unity Ads Helper asset package.
    6. From Edit > Unity Ads Settings, enter your game IDs in the fields provided.
      Note: Your game ID can be found under your game profile in the Unity Ads Admin.
    7. Select GameObject > Create Empty from the menu to create a new GameObject.
    8. Add the following scripts to the new GameObject:
      • UnityAdsHelper.cs – found in UnityAdsHelper/Scripts
      • ShowAdOnLoad.cs – found in UnityAdsHelper/Example/Scripts
    9. Save and press the Play button to test Unity Ads in the Editor.
    10. Build and Run your app to test Unity Ads on your device.
    Please see the README for additional documentation on using the new Unity Ads Helper.

    For more examples, take a look at this Unity Ads Demo project. The README has more details.

    A video walkthrough covering Unity Ads for Android in Unity, made by Salazar, is also available.

    Here's another video tutorial for Unity Ads, available in the Unity Live Training Archive.

    If you need the use of Server-to-Server Redeem Callback functionality, try out this server-side example.

    NOTE: S2S Redeem Callbacks are not necessary for rewarding users (a callback method can be used instead). This is an extended feature offered as a way to confirm that users actually watched videos through to completion. You would still need to configure your server to communicate back to the app that the user should then receive a reward.
     
    Last edited: Aug 1, 2015
  2. kenli

    kenli

    Joined:
    May 20, 2013
    Posts:
    6
    unity-nikkolai likes this.
  3. Nothnless

    Nothnless

    Joined:
    Oct 10, 2014
    Posts:
    38
    Where do you find your game ID?
     
  4. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    You have to publish a game before you get a game ID (missing from steps).
     
  5. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    You're right, creating a game ID is missing from the steps in this guide. However, you do not need to have a published game before you can create a game ID.

    If you have not yet created a game in the Unity Ads Admin, select Games from the left nav panel and select the Add New Game button at the top of the Games page. Then select either iOS or Android as your release platform (you'll create one game ID per platform that you want to support). If your game has already been published to the App Store or Google Play, enter the URL for the store page into the lookup tool.

    If your game has not yet been published, you can enter the name of your game instead. See the note and hyperlink under the lookup tool.

    Screen Shot 2015-02-10 at 8.06.51 AM.png

    After your game profile has been created, select Games from the left navigation panel to view your list of games. You will find your game ID listed in the same row as your game name under the Game ID column. It's also displayed at the top of each of your game pages.

    Screen Shot 2015-02-10 at 8.27.21 AM.png
     
  6. Deleted User

    Deleted User

    Guest

    Can any one upload a complete video tutorial for using unity ads to a new project?
    I am trying everything described above. But does not work. I need a immediate solution.
     
  7. Hagen

    Hagen

    Joined:
    Aug 16, 2014
    Posts:
    35
  8. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Those links should still work. Are you getting an error? I was able to access them, even after logging out of GitHub.

    Attaching the files below, just in case there's some reason you can't access GitHub.
     

    Attached Files:

  9. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    When integrating Unity Ads for the first time, it's best to enable test mode. I've added a note to the steps above.

    Ideally you want test mode enabled when you're developing your app. Then before you build and submit it to the store, you want to disable test mode. Using Unity, you typically have Development Build enabled when developing your app, but you turn it off before submitting. So in the UnityAdsHelper script, I've loosely coupled the two options.

    Unity Ads test mode is disabled and enabled depending on whether Development Build is disabled or enabled. However, when Development Build is enabled, you can still disabled test mode from the UnityAdsHelper options in order to see live ads with Development Build enabled.

    If you are able to see ads with test mode enabled, but not able to see live ad with test mode disabled, there's a possibility that there are no more ad campaigns available for your region.

    Be sure to enable Development Build in Build Settings to allow the use of test mode for Unity Ads, and uncheck the option to "Disable Test Mode" from the UnityAdsHelper script.

    Screen Shot 2015-02-12 at 7.46.38 AM.png
     
  10. Hagen

    Hagen

    Joined:
    Aug 16, 2014
    Posts:
    35
    got it, it seems an issue with the firewall.
    Thanks
     
  11. Deleted User

    Deleted User

    Guest

  12. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Can you copy the debug output from the device to a file and post it here?
     
  13. Deleted User

    Deleted User

    Guest

    I am using your two new script. Now it Works.

    Thanks
     
  14. rezki

    rezki

    Joined:
    Oct 15, 2013
    Posts:
    53
    Do i need my game to be in the google play store in order to generate revenue from unity ads ?
    because i'm not planning to put it on the play store
     
  15. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    No, it doesn't need to be on the Play Store. Where do you plan on releasing your game?
     
  16. rezki

    rezki

    Joined:
    Oct 15, 2013
    Posts:
    53
    @unity-nikkolai

    I'm planning a facebook game that will be on both canvas and android
     
  17. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Just keep in mind, Unity Ads only supports iOS and Android. It doesn't support web or standalone desktop builds.
     
    Salazar likes this.
  18. GladisAd

    GladisAd

    Joined:
    Oct 5, 2014
    Posts:
    28
    Very useful, and simple, integration guide. Thanks @unity-nikkolai. One thing I have noticed, is that if there is no wi-fi the ads don't run at all, is there a way to ensure that:
    1) Ads work using mobile networks if there is no wi-fi.
    2) Maybe adding a function that prevents the player from playing the game unless there is network coverage.

    Many thanks.
     
    Last edited: Feb 14, 2015
  19. GladisAd

    GladisAd

    Joined:
    Oct 5, 2014
    Posts:
    28
    My mistake, it seems to have stopped working completely, for no apparent reason?
     
  20. sak45

    sak45

    Joined:
    Feb 12, 2015
    Posts:
    3
    In UnityAdsHelper.cs
    what line that I add game id?
     
  21. Salazar

    Salazar

    Joined:
    Sep 2, 2013
    Posts:
    235
    Hello sak45,

    - Attach helper script to a gameobject
    - Select object from hierarchy panel
    - In the inspector panel, you should see IOS,Android fall down menus.
    - Enter your game ID to its slot
    - If you are not using development mode, dont forget to disable test ads from helper script panel before publish your app.

    Regards,
     
    unity-nikkolai and sak45 like this.
  22. sak45

    sak45

    Joined:
    Feb 12, 2015
    Posts:
    3
    Thank you Salazar, I wii try it
     
  23. Mike-Nate

    Mike-Nate

    Joined:
    Feb 17, 2015
    Posts:
    3
    Really helped me a lot !!!
     
    unity-nikkolai likes this.
  24. wen9

    wen9

    Joined:
    Feb 17, 2015
    Posts:
    12
    I am Chinese,so i can not put my game on the play store。can i put it on other markets?
     
  25. sak45

    sak45

    Joined:
    Feb 12, 2015
    Posts:
    3
    I follow these step and I can build apk file but Ads don't show.
    How to solve it?

    Regards,
     
  26. Salazar

    Salazar

    Joined:
    Sep 2, 2013
    Posts:
    235
    Hello sak45 ,

    I made a video about implementation. Could you please follow that tutorial, and than if its not enough let me know here.
    Audio is a bit low but hope it helps.

    Regards,
     
    sak45 and unity-nikkolai like this.
  27. Sonu-Modi

    Sonu-Modi

    Joined:
    Feb 27, 2015
    Posts:
    2
    Thanks ! I think every thing is working but when I try to "Build" my android app, following given error is shown
    to the consol. Will you please help me .

    Error building Player: Win32Exception: ApplicationName='javac.exe', CommandLine='-bootclasspath "E:/ANDROID PROGRAMMING/ADT/adt-bundle-windows-x86_64-20140702/sdk/platforms/android-21\android.jar" -d "E:\Unity 4.3 training\My Rough works\Roll - Intelligently - Copy\Temp\StagingArea\bin\classes" -source 1.6 -target 1.6 -encoding UTF-8 "com\ultraaim\sonu\R.java" "com\unity3d\ads\android\R.java"', CurrentDirectory='E:\Unity 4.3 training\My Rough works\Roll - Intelligently - Copy\Temp\StagingArea\gen'

    Even I do get the blue screen during playing in unity.... which shows... "Here would be your ad unit. (Things Seems to be Working.)"

    Please help.
     
  28. Salazar

    Salazar

    Joined:
    Sep 2, 2013
    Posts:
    235
  29. Sonu-Modi

    Sonu-Modi

    Joined:
    Feb 27, 2015
    Posts:
    2
    Thanks Again...
    That Error has been gone..... now I will proceed .
     
    Salazar likes this.
  30. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Thanks for the guide @unity-nikkolai, up and running in minutes!
     
    unity-nikkolai and Salazar like this.
  31. andreimik

    andreimik

    Joined:
    Mar 6, 2015
    Posts:
    2
    I have a question
    These two files enough.
    or still need unity sdk.
    ---------------------------------------
    I put the game in your 2 files
    and unity sdk
    to compile the game in .apk file
    opened the game on the phone screen is not working point
     
  32. andreimik

    andreimik

    Joined:
    Mar 6, 2015
    Posts:
    2
    New I have a question
    These two files enough.
    or still need unity sdk.
    ---------------------------------------
    I put the game in your 2 files
    and unity sdk
    to compile the game in .apk file
    opened the game on the phone screen is not working point
     
  33. Salazar

    Salazar

    Joined:
    Sep 2, 2013
    Posts:
    235
    Hello andreimik ,

    Yes, you still need the unity ads assetstore package. There is a walktrough video here , which covers integration steps. If you have further questions, let me know.

    Regards,
     
  34. shubham_goel

    shubham_goel

    Joined:
    Mar 8, 2015
    Posts:
    1
    Ads show in editor but not when i run the game in device..
     
  35. Salazar

    Salazar

    Joined:
    Sep 2, 2013
    Posts:
    235
  36. D_Cergy

    D_Cergy

    Joined:
    Feb 18, 2015
    Posts:
    35
    Hi,

    It works on the editor, but in device the ads didn't show. My connection seems okay. The game is not published yet. Used test mode with 2 scripts provided above. I tested it from Indonesia.

    I saw this line in the log :
    03-11 02:51:19.678: I/Unity(21992): Error: Video ad server resolves to localhost (due to ad blocker?), can't initialize ads
    I didn't use any ad blocker, it's a new phone. Tested on other device as well, and didn't work too.

    And, what is the purpose of another TestGameID if we could actually use the real one with test mode enabled?
     
  37. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    What device and OS version are you using to test with? The reason that error message comes up is because the device is resolving the URL for our ad server to IP address 127.0.0.1, which is the localhost address for your device. The only cases in which we've seen this is when some form of ad blocker is installed.

    You can use the real one. You don't have to enter a value for the test one. The test one is only used if your provide a game ID and test mode is enabled.

    Having a second game ID for testing was meant to keep stats generated during development from affecting your real game ID stats. The other reason to have a test game ID is if you're using Server-to-Server Callbacks and have testing servers as well as production servers for handling the callbacks. These are edge cases, though. I'm going to remove these secondary test game IDs from the UnityAdsHelper script when I introduce the new demo project for Unity Ads.
     
    Salazar likes this.
  38. D_Cergy

    D_Cergy

    Joined:
    Feb 18, 2015
    Posts:
    35
    Actually its a reseted and fresh Android 5.0.2 Lollipop Moto G. And the other one using Lenovo with Android 4.2.2 Jellybean. Haven't tried it on iOS. And I think I haven't installed any sort of ad blocker, only Facebook, WhatsApp and Line Messenger. The both devices showing the same error log.

    Okay I got it, thanks for the explanation :)
     
  39. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Are you using Unity Ads 1.1.2 from the Asset Store? This latest version was released yesterday.
     
  40. D_Cergy

    D_Cergy

    Joined:
    Feb 18, 2015
    Posts:
    35
    I think I used the 1.1.0, I downloaded it just before the 1.1.2 version released. I updated the package to 1.1.2, and the ads showing in my Lenovo devices (I have 2, both of them show the ads).
    But the ads still not showing in my Moto G, freshly installed Lollipop 5.0.2.

    This is the log I saw :
    03-13 00:46:12.913: I/Unity(11843): Error: Video ad server resolves to localhost (due to ad blocker?), can't initialize ads
    03-13 00:46:28.125: W/Unity(11843): Unity Ads failed to initialize in a timely manner. Ad will not be shown on load.


    Maybe the Lollipop have a sort of ad blocker integrated in. Another info, the OS came in minimal addition from Motorola without their utilities apps, maybe because it's a Google owned company.
    Thank you for your help Nikkolai
     
  41. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Hmm, maybe consider resetting the device to factory conditions. Might also be worth checking out Motorola's developer portal. They have details there for how to flash the system with a factory image if necessary.
     
  42. Unity3dteacher

    Unity3dteacher

    Joined:
    Dec 14, 2012
    Posts:
    197
    @Unity Nikolai :how long time does it take to show datas on unityads STATISTICS after user has watched video?.
     
  43. VirusXProgramming

    VirusXProgramming

    Joined:
    Nov 15, 2014
    Posts:
    67
    What are the rules and eula etc for this?
     
  44. daksheshkothari

    daksheshkothari

    Joined:
    Jan 24, 2013
    Posts:
    2
    Hey.
    Anybody getting an issue in ios device like below
    if video ad is running and you press the home button and then came back to game again,Ad just disappear without completing.
    and is there anything special action need to taken while building project from unity 4.6.1 to Xcode 6
    Because i am getting some errors in Xcode.

    Thank you...
     
    Last edited: Mar 16, 2015
  45. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    It's open for public use, modification, and reuse. Feel free to use any part of the demo in your projects and repurpose it to suite your own needs.
     
    Salazar likes this.
  46. VirusXProgramming

    VirusXProgramming

    Joined:
    Nov 15, 2014
    Posts:
    67
    Ok thanks!
     
  47. Landci

    Landci

    Joined:
    Aug 28, 2012
    Posts:
    33
    any help on how to use the rewarded video ads?
    You guys really need to update the knowledgeable of unity ads!!!

    it says something with
    UnityAdsVideoCompleted(string rewardItemKey);

    i cannot find that in the current version, any advise is appreciated!
     
  48. jannen

    jannen

    Unity Technologies

    Joined:
    Aug 21, 2014
    Posts:
    28
    unity-nikkolai likes this.
  49. NathanHale1776

    NathanHale1776

    Joined:
    Mar 22, 2014
    Posts:
    46
    We are trying to use this in our game but we are getting this error from xcode:
    file:///Users/yagddda/Desktop/asasasasas/LaunchScreen.xib: warning: Unsupported Configuration: Constraint referencing items turned off in current configuration. Turn off this constraint in the current configuration.

    (null): error: /Users/yagddda/Desktop/asasasasas/UnityAds/UnityAds.bundle: No such file or directory

    We used the guide in this thread, can someone help? tyvm
     
  50. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Under Player Settings, make sure Launch Screen Type is set to Default under the Splash Image section.

    Additionally, from the Other Settings section, make sure Scripting Backend is set to IL2CPP and Architecture is set to Universal. When building to iOS from Unity, select the option to Replace the Xcode project instead of Append.

    Also make sure you have the latest patch version of Unity installed.