Unity SDK For Xiaomi Alpha v0.0.1 Ads Guide
Unity SDK For Xiaomi Alpha v0.0.1 Ads Guide
If you are unable to access the Unity Ads admin using the UDN login, please contact us and provide us
with your developer ID, your UDN email address or username, and the email address you normally use to
log into the Unity Ads admin.
Instead of entering your email and password into the existing login prompt as you normally would, try
logging in through the UDN instead. Select UDN Login or Sign Up and follow the prompt.
If you are unable to login using the UDN login, please contact us and provide us with your email address
and the developer ID of your account.
If you are logging in through the old Unity Ads admin, select UDN Login or Sign Up.
When you log in for the first time, you will be prompted to complete your Unity Ads account setup. If you
are a member of any UDN organizations and are an owner, you will have the option of selecting one of
these organizations for use as your Company.
Note: If you are using the old Unity Ads admin, the organization can only be set during the initial registration process. If your role in
the organization is set to Owner, the organization be selectable from the Company dropdown field in the sign-up form. If you do not
see your organization in the dropdown, please double check your role in the organization. Please contact us if you are still unable to
see your organization as an option in the sign-up form.
If you need to change your organization after registration, please contact us and let us know which organization you would like to
change it to. Also, please be sure to provide us with your developer ID, and the developer ID of the new organization.
Monetization
Integration Guide for Unity
Quick Start
Before going into too much detail, let's start off with a simple integration example. Every Unity Ads
integration boils down to just 3 basic steps:
The following example initializes Unity Ads on Start, and shows the default ad placement when ready. If
the Ads service is enabled in the Services window, Unity will initialize Unity Ads for you instead. The rest
of the example is the same, regardless of whether you are using the Services window or the Unity Ads
asset package.
C# Example – ShowAdOnStart.cs
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements; // Using the Unity Ads namespace.
IEnumerator Start ()
{
#if !UNITY_ADS // If the Ads service is not enabled...
if (Advertisement.isSupported) { // If runtime platform is supported...
Advertisement.Initialize(gameId, enableTestMode); // ...initialize.
}
#endif
#pragma strict
import UnityEngine.Advertisements; // Import the Unity Ads namespace.
To get started with your Unity Ads integration, follow these steps to setup and initialize Unity Ads using
the Unity Ads asset package.
1. Select Assets > Create > C# Script from the Unity menu.
2. Enter UnityAdsExample as the name and press the return key.
3. Right-click the script and select Open to begin editing it.
4. Copy the following example code into the script:
C# Example – UnityAdsExample.cs
using UnityEngine;
using UnityEngine.Advertisements;
[SerializeField]
private bool testMode;
void Start ()
{
string gameId = null;
#if UNITY_ANDROID
gameId = googleGameId;//For GooglePlay store
// Or
gameId = xiaomiGameId;//For Xiaomi Mi GameCenter
#elif UNITY_IOS
gameId = appleGameId;
#endif
Step 6: With the GameObject selected, set the Game ID field in the Inspector window.
If you don't know what your Game ID is, you can find it in the list of platforms for your project in the Unity Ads dashboard.
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements;
void Start ()
{
string gameId = null;
// Or
gameId = xiaomiGameId; //For Xiaomi Mi GameCenter
#endif
Please be aware that you are prohibited under the Unity Ads Terms of Service agreement from generating impressions or installs by
clicking on ads within your own game. Doing so will put you at risk of being banned from the Unity Ads network for attempted fraud.
As a precaution, it is best to leave Test Mode enabled during development and while testing Unity Ads.
If you are using the Services window in Unity 5.2 or later, Test Mode for Unity Ads will be disabled by
default. You can enable or disable this option under Settings for Ads in the Services window.
If you are initializing Unity Ads using the Advertisement.Initialize method instead, Test Mode can be set
by passing a boolean value as the second parameter to the method. Please see the Scripting API for
further details.
When you get ready to publish your game, Test Ads should be disabled. You can either disable it in Unity
before creating your submission build, or you can disable it from the Unity Ads dashboard under under
the Settings tab of each platform in your project.
If you are still using the old Unity Ads admin, the Test Mode settings can be found under the Monetization
Settings tab of your game profile.
Showing an Ad Placement
This section covers how to simply show an ad placement.
Create a new C# script called UnityAdsButton, and add it to a new GameObject in your scene. Then copy
the following code into the script:
C# Example – UnityAdsButton.cs
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements;
Create a new C# script called UnityAdsRewardedButton, and add it to a new GameObject in your scene.
Then copy the following code into the script:
C# Example – UnityAdsRewardedButton.cs
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements;
void OnGUI ()
{
if (string.IsNullOrEmpty (zoneId)) zoneId = null;
● Classes
○ UnityEngine.Advertisements.Advertisement
○ UnityEngine.Advertisements.ShowOptions
● Enumerations
○ UnityEngine.Advertisements.Advertisement.DebugLevel
○ UnityEngine.Advertisements.ShowResult
Quickstart guide
Create a new game project in the Unity Ads dashboard
Log into the Unity Ads Dashboard using your UDN account.
Locate the (7-digit) Game ID by selecting your game project. You will use this number to activate Unity
Ads.
Locate your placement IDs by selecting a Game ID (AppStore, GooglePlay or Mi GameCenter), then
clicking the Placements tab. Initially, each game ID has two placements:
● video (default / skip video after 5 seconds)
● rewardedVideo (no skip option)
Enable test mode for each game ID under the settings tab.
Unity Ads SDK 2.0 takes activity argument in each show method invocation (this in the above example).
See Unity Ads Android API reference for more information on the API, e.g. showing ads for different
placements and refer to the example application for an example on how to implement the Unity Ads SDK
into your project.
The following article by Unity Ads evangelist Oscar Clark explores several integration examples from
successful games, and discusses what not to do as well.
To get an idea of just how much rewarded video ads can impact your game, check out the following blog
post. The info graphics within are the distillation of results from the more than 2,000 mobile game
developer surveyed.
Please contact us with any questions or comments you might have about designing your game with Unity
Ads in mind.
Intro to Ad Placements
What are ad placements
Ad placements allow you to have better control on where and how your ads are shown in the game.
If you wish to show rewarded ads - where a user gets a coin/gem/extra life for watching a video, you can
use a placement with skipping disabled.
If you need more than the two default placements (for e.g. tracking), you can create new placements in
the Ads dashboard.
It's up to you when to actually show the ads, but to get an idea about using different placements, take a
look at our example game (Space Ads):
https://github.com/Applifier/unity-ads-demo
if(UnityAds.canShow()){
UnityAds.setZone("PLACEMENT ID");
UnityAds.show(options);
}
Advertising
Getting Started
Self-Service User Acquisition
This document serves to help marketers quickly get started with user acquisition campaigns through
Step 4: Head over to the Unity Ads signup page and register for the Unity Ads service
Add a Game
The next step after creating and verifying your account is to add a game. All campaigns and creatives will
be stored at the game level in the Unity Ads dashboard.
Step 2: Hit "Add New Game" to begin the process of adding your game
Step 3: Select which platform your game is live on and input your game's store URL. Then, scrape the
app store using the "Look Up Application" button
Step 1: Head into the game you just added. To do this, select "Games" from the left-hand side of the
dashboard, select the game by clicking on the game name, and then head over to the "Ad Creatives"
Step 2: By default, we create an empty creative pack for you. Select this creative pack by clicking on
"Video Creative Packs"
Step 3: Once you're inside of the default creative pack, you can drag and drop your video and end cards
into their respective field. For more information on our creative specs, check out the Video Creative
Documentation. Make sure to save your creative pack after everything has uploaded properly (you'll see
"Asset uploaded successfully")
Set Up a Campaign
Now that you've added your game to the dashboard and creatives to your game, its time to set up a new
campaign.
Step 1: Head back into your game, but this time select "Ad Campaigns", then select "+ Create a
Campaign Now" and go through the campaign set up process:
Ad Type: The type of ad you'd like to run on our network (required - only video ads available at this time)
Campaign Type: The payment method you'd like to use for this campaign
● CPI - Cost per Install. You will only be charged when a user installs your app (recommended)
● CPV - Cost per Completed View. You will be charged every time a user completely watches one
of your video ads
Budget Type: The type of budget you'd like to use for this campaign
● Single budget - this budget input will only be used for this campaign
● Shared budget - you can use this option if you wanted more than one campaign to share a single
budget
Scheduling: The start and end date that you want to run your campaign for. By default, there won't be an
end date
Creatives Pack: This is the video that will run on this specific campaign. You can select "Change" to
change to a different creative pack. Keep in mind that you'll only see one creative pack by default, unless
you've added more than one creative pack.
Countries and Prices: In this section, you can change the countries that you want this campaign to target,
as well as set the prices for each of those countries. First, click on "Change", which will open up the
expanded targeting window.
Search the country you want to target by using the "Type country to search" box and hit enter to add that
country to the targeting list. You can then change the bid by clicking on the country code box. This will
bring up a pop-up window where you can change the bid. Hit "OK" to save the bid for that country.
Targeting:
● Operating System Targeting: The minimum and maximum Operating System targeting parameter
allows you to target a specific range of operating systems
● Device Targeting: The device targeting section allows you to target a series of devices (iPad,
iPhone, iPad) or a specific device (iPhone 6, iPad Mini 3). This granular targeting is only available
on iOS, but will be coming to Android in the near future. Android targeting is broken down by
screen size.
● Connection Targeting: This allows you to target users that are connected to WiFi or a cellular
connection. If your game is above the download limits (iOS - 100mb/ Google Play - 50mb), then
we suggest targeting WiFi only, as users on cellular wouldn't be able to download your game
(which lowers conversion rates and makes you less competitive in our network).
Designing Campaigns
This design guide outlines the requirements for creating a Unity Ads campaign.
Video Asset
The video used to promote your game should be between 15 and 30 seconds in length, with a
widescreen resolution of 640×360 pixels (16:9 aspect ratio).
We do support a wide range of video formats. However, to help ensure that your video upload is accepted
by us, please use one of the recommended formats listed below.
Video Specifications
● Resolution: 640×360 pixels (16:9).
● Length: 15 to 30 seconds.
● File Format: H.264-encoded MOV, MP4, or AVI file formats.
● File Size: Recommended size is 10MB. Maximum size is 30MB. Videos will be re-encode to be
suitable for various bitrates. The final video shown will be optimized for the user's available
network speed and cache settings.
● For iOS Only: If the video contains more than one store logo, App Store logo should always
appear in first position.
Optimizing Campaigns
When launching a user acquisition campaign, you want to be sure that you are utilizing all possible levers
at your disposal in order to get the most performance out of your campaigns. Of course, raising your bids
to competitive levels is the most obvious and one of the most effective ways of increasing volume.
However, there are several other ways to optimize without touching your campaign spend. Here we will
go over some of the best practices you can implement in order to achieve such results.
● Choose your geo targets carefully. You might already know what countries perform best for you,
and you can assign each a different bid accordingly. If you are just starting out with user
acquisition and have not gathered enough data to ascertain what performs best, we recommend
first launching in the US, United Kingdom, Canada, and Australia. As you gather data and want to
explore more opportunities, you might consider expanding to other English-speaking countries,
countries in Western Europe, and the Nordic countries. Conduct periodic reviews of per-country
performance and adjust bids from time to time.
● Break out your iOS campaigns to target different bids for iPad and iPhone. iPad users generally
tend to be higher quality users than iPhone, so we recommend a higher bid there.
● If you are targeting non-English speaking countries, it is best to run localized versions of your
trailer and static thumbnails/endcards.
Once this parameter is in place, wait until you have collected a statistically significant amount of internal
data regarding publisher performance. Then, analyze the user quality data per publisher according to your
key metrics (LTV, ARPU, etc). Send Client Services a list of the low quality publishers, and we can block
these for you.
Overview
The statistics API works in two stages: First, the user performs an GET request to an authentication
server which, after a successful authentication, responds with a 302 HTTP redirect message. This
response contains a the final URL to the statistics server.
Next, when the user performs an GET request to the signed URL, the located server will respond with the
requested data in CSV format in the body of the message:
Authentication
In order to use the Unity Ads Statistics API, you need to get the API key from the Unity Ads Admin Panel.
The API key is located in the Account Settings page.
The API key needs to be placed in the authentication request to the apikey HTTP GET parameter.
After a successfull authentication the server will respond with a 302 HTTP-redirect message with the data
URL to the statistics server located in the Location HTTP-header. The real data is fetched from this
given redirect URL. This is a standard HTTP behavior and is supported by all HTTP clients. For example
curl -L
"http://gameads-admin.applifier.com/stats/acquisition-api?apikey=APIKEY" will
directly output the file to the console.
The statistics server always requires signed URLs and will not work if accessed without a valid signature.
If the authentication fails, the authentication server will respond with an HTTP/1.1 200 OK header with an
error message in the body:
{"error":"Authentication error","responseCode":500,"status":"error"}
Request Format
http://gameads-admin.applifier.com/stats/acquisition-api?apikey=<apikey>&fields=<fields>[&spli
tBy=<splitbyfields>][&scale=<scale>][&start=<startDate>][&end=<endDate>]([&targetIds=<targetId
s>]|[&campaigns=<campaignIds>]
where:
● <apikey> is the api authentication key retrieved from the Unity Ads Admin Panel
● <fields> contains a comma separated list of available fields:
○ started - number of impressions recorded
○ views - number of completed views recorded
○ clicks – number of clicks recorded
○ installs – number of installs recorded
○ spend – how much money was spent
Note: Splitting the statistics data across multiple dimensions at the same time grows the data size
exponentially. The processing time might end up being too long and cause the request to fail. All the
requests taking more than a minute to generate the data will be terminated at 60 seconds.
● <scale> – contains the time resolution of the data. Each day is split at 00:00 UTC. The
available values for scale are:
○ all – removes time resolution completely and provides the total sum of values within the
defined period
○ hour
○ day
○ week
○ month
○ quarter
○ year
● <startDate> & <endDate> – contains the start (inclusive) and end (exclusive) times for the
data. The dates are accepted in following formats:
○ negative numbers are treated as days relative to the current date. For example: -7 is a
week ago.
○ Date string in ISO format YYYY-MM-DDTHH:mm:SS:hhhZ, for example:
2013-02-01T14:00:00.000Z
The default start date is -7 and end date is 0 to get the past week’s data.
Note: The start and end dates will be rounded upwards to next full hour. For example, the
14:00:05.000Z will be rounded to 15:00:00.000Z. Also note that if using scale day, using
non-midnight <startDate> & <endDate> will still select the range per hour and not the whole day.
● <targetIds> – comma separated list of target game ids to filter the results. By default, all the
games of the advertiser will be included.
● <campaigns> – comma separated list of campaign ids to filter the results. By default, all the
campaigns of the advertiser will be included.
● Note: The results can be filtered by either target games or campaigns, but not both at the same
time.
Example:
curl -L
"http://gameads-admin.applifier.com/stats/acquisition-api?apikey=c4ca4238a0b923820dcc509a6f758
49bc81e728d9d4c2f636f067f89cc14862c&splitBy=campaign,country&fields=views,clicks&start=-31&sca
le=all&targetIds=8234,7432"
Response Format
CSV format in general
The statistics server will output the requested statistics data in the HTTP response body. The data is in
CSV format. Comma ‘,’ is used as the field separator and dot ‘.’ as the decimal separator. Text fields will
have double quotes (‘”‘) around them. Pure integer fields don’t have double quotes, but decimal numbers
(such as revenue and spend) are doublequoted. The unix newline character (0x0D) is used as the line
separator. The first line of the output will contain the field names.
Fields
The leftmost field is always the Date. The date is in ISO format YYYY-MM-DD HH:mm:SS.
The next fields are the split dimensions (if selected) in the following order:
● For source splitted data, two fields "Source game id" and "Source game name" will be shown.
Game id is an integer.
● For target splitted data, two fields "Target game id" and "Target name" will be shown.
● For campaign splitted data, two fields "Target campaign id" and "Target name" will be shown.
● For country splitted data, two fields "Country code" and "Country tier" will be shown. Country
code is the ISO 3166-1 alpha-2 country codes in upper case based the users’ GeoIP data. " --" is
shown for those user IPs whose GeoIP location was unknown. - - The country tier is an integer
denoting country’s classification in Applifier’s tier structure.
The rightmost fields are the data fields requested in the same order as in the request.
For example:
$ curl -L
"http://gameads-admin.applifier.com/stats/acquisition-api?apikey=c4ca4238a0b923820dcc509a6f758
49bc81e728d9d4c2f636f067f89cc14862c&splitBy=country,campaign"
Date,Target campaign id,Target name,Country code,Country tier,clicks,installs,spend
2013-03-01 00:00:00,"50ed569d57fe1f324a15fbf7","Campaign #5","AU",2,71,30,"45.00"
2013-03-01 00:00:00,"50ed569d57fe1f324a15fbf7","Campaign #5","CA",2,129,88,"132.00"
2013-03-01 00:00:00,"50ed569d57fe1f324a15fbf7","Campaign #5","US",1,1745,855,1282.50
2013-03-01 00:00:00,"50eeb7339e10c9d21c0225cb","Campaign #6","AT",3,39,19,"28.50"
2013-03-01 00:00:00,"50eeb7339e10c9d21c0225cb","Campaign #6","AU",2,16,10,"15.00"
2013-03-01 00:00:00,"50eeb7339e10c9d21c0225cb","Campaign #6","BE",3,209,120,"180.00"
2013-03-01 00:00:00,"50eeb7339e10c9d21c0225cb","Campaign #6","CA",2,284,179,"268.50"
2013-03-01 00:00:00,"50eeb7339e10c9d21c0225cb","Campaign #6","CH",3,15,7,"10.50"
...
Unity Ads Install Tracking SDK
Get the UnityAdsInstallTracking package from your account manager.
Obtain your game id from the advertiser dashboard or your account manager. Ensure that you are using
the correct ids for each app being published in different store (Apple AppStore, GooglePlay, Xiaomi Mi
GameCenter ). For Xiaomi integrations please follow the instructions for Android or Unity package
integration.
iOS
Extract the `UnityAdsInstallTracking.framework.zip` file and add the resulting
`UnityAdsInstallTracking.framework` to your Xcode project app target.
Objective-C:
```
[UnityAdsInstallTracking track:@"YOUR_APPSTORE_GAME_ID"];
```
Swift:
```
UnityAdsInstallTracking.track("YOUR_APPSTORE_GAME_ID")
Android
Unity Package
Import generated ```UnityAdsInstallTracking.unitypackage``` to your project.
For simple testing, use the following script & attach it to a game object in your scene:
`InstallTrackingBehaviourScript.cs`
```
using UnityEngine;
using UnityEngine.InstallTracking;