WGPlayer SDK
Connect your game. Start earning in minutes.
Drop-in SDKs for Unity, Construct 2, Construct 3, and plain JavaScript. Midroll and rewarded ads: one integration, every popular game platform.
- 4platforms supported
- 2ad formats included
- 5 minaverage integration time
<script>!function(l){
var b="https://universal.wgplayer.com/tag/?",
p="&wp="+l.pathname+"&ws="+l.search;
function load(h,fb){
var s=document.createElement("script");
s.async=1;
s.fetchPriority="high";
s.src=b+"lh="+h+p;
s.onload=function(){
if(fb&&!window.wgDomainOnboarded)
load("wgplayer.com")
};
s.onerror=function(){
if(fb) load("wgplayer.com")
};
document.head.appendChild(s)
}
load(l.hostname,1)
}(location)</script>Pick your engine
Unity
Package V3.1New What changed in Package V3.1 (October 2026)
- When a midroll is refused (for example, requested too soon after the previous one), the game keeps running instead of staying paused.
- Keyboard focus goes back to the game after an ad.
- Newer Unity versions no longer need the
gameInstanceassignment inindex.html. - The example scene moved to
Assets/WeeGooAdsManager/Example/, so importing the package never overwrites your own scenes.
Games built with an older plugin or package keep working; switch to the new version the next time you export your game.
Unity integration · midroll ads
The WGSDK communicates between your Unity game and the browser. The package ships with WeeGooExampleScene.unity (in Assets/WeeGooAdsManager/Example/) and MyGame.cs as references — drop them once you have your own integration working.
Prerequisite
Install the WGPlayer Universal Tag
Before anything else, make sure the WGPlayer Universal Tag is in your game's index.html inside the <head> section.
<!-- WG Universal Tag -->
<script type="text/javascript" async>
!function(e,t){
a=e.createElement("script"),
m=e.getElementsByTagName("script")[0],
a.async=1, a.src=t,
m.parentNode.insertBefore(a,m)
}(document,
"https://universal.wgplayer.com/tag/?lh=" + location.hostname
+ "&wp=" + location.pathname
+ "&ws=" + location.search);
</script>
Download the SDK and add it to Unity. The package contains example scenes and scripts.
Step 1
Import the Unity package
The archive contains a Unity package file. Import its contents into your game project (Assets › Import Asset Package, or Assets › Import Package › Custom Package in older Unity versions).

Updating
Already using an older package? Import the new one over it and accept the overwrite. Your WeeGooAdManager settings in the Inspector are kept. An old Assets/Scenes/ExampleScene.unity from a previous package stays in your project; the new package no longer touches it.
Step 2
Drag the WGSDK Prefab into your scene
From the Project panel, drag the WGSDK Prefab to your Hierarchy panel.

Step 3
Configure WGSDK defaults
Update the WGSDK default values to fit your needs. If you're unsure, the defaults are safe.

In the image above, look at the Wee Goo Ad Manager (script) panel. Two options control behavior: Ad Interval and Show Ad Every N Events.
Ad Interval — when greater than 0, the Ads Manager automatically calls a midroll every N seconds. Useful for slower-paced games (e.g. chess) where setting this to 240 shows an ad every 4 minutes.
Show Ad Every N Events — postpones the ad display. Imagine a game with very short levels where the user restarts every 30 seconds: showing an ad every 30 seconds is awful UX, so this lets you show it once every N restarts (set to 2 to show every other call).
Step 4
Bind a button to the WGSDK Prefab
Create a button and bind its click event to the WGSDK Prefab. This lets you call the GetAd function from a button click.

Step 5a
Show midroll using a button
Now you can use the WeeGooAdManager to display midroll ads from a button click.
Select the button in the Hierarchy panel and look at the Inspector panel — find the On Click area. Click the lower-right plus (+) sign to add a new action. Drag the WeeGooAdManager object from the Hierarchy panel into the On Click — None (object) field in the Inspector panel.

Click the No function dropdown, hover WeeGooAdManager, and click GetAd. In a real game, this could fire every Nth time a user clicks the next-level button.
Note
The ad will only display in a live environment with a valid WGPlayer AFG implementation. To confirm the component is integrated, check the developer console in your browser.
Step 5b
Show midroll from a script
If you need to call the ad from an existing script, update it as shown below.

With Show Ad Every N Events at its default (1), every call to PlayerHasDied requests an ad. Set it to 5 and the function needs to be called 5 times before an ad displays.
Whether you trigger the ad from a button or a script, the component automatically pauses and resumes the game based on the ad state.
Final note
Newer Unity versions
From package V3.1 this step is not needed: the package connects to the game by itself. With an older package, newer versions of Unity need unityInstance assigned to gameInstance in index.html:
// ...
var gameInstance; // Define the gameInstance variable here
script.onload = () => {
createUnityInstance(canvas, config, (progress) => {
spinner.style.display = "none";
progressBarEmpty.style.display = "";
progressBarFull.style.width = `${100 * progress}%`;
}).then((unityInstance) => {
gameInstance = unityInstance; // make sure to have this assignment
loadingCover.style.display = "none";
if (canFullscreen) {
if (!hideFullScreenButton) {
fullscreenButton.style.display = "";
}
fullscreenButton.onclick = () => {
unityInstance.SetFullscreen(1);
};
}
}).catch((message) => {
alert(message);
});
};
// ...
Unity integration · rewarded ads
Rewarded ads give the user a prize in exchange for watching. Three events fire: OnReady, OnSuccess, OnFail. Wire callbacks to each.
Step 1
Drag the RewardControl Prefab
From the Project panel, drag the RewardControl Prefab into your scene. The prefab is a demo — replace it with your own game logic when you're ready.

Step 2
Subscribe to reward events
Focus the WeeGooAdManager Prefab and subscribe to reward events in the Inspector panel:
- On Ready — a reward is ready. Show or activate the call-to-action element.
- On Success — the ad finished; the user should receive the reward.
- On Fail — the ad was closed early; the user should not get the reward.
The reward call-to-action element should only be visible after OnReady fires. Hide it after each Success or Fail — it'll re-appear when OnReady fires again.

See MyGame.cs and WeeGooExampleScene in the package for full details.
About rewarded ads
Test mode vs production
While testing and debugging, we use a special test ad unit that returns test ads for every request.
Before publishing your game, contact us with your developer endpoint (site or name) so we can manually enable production rewarded ads.
Construct 2
Plugin 1.0.8New What changed in Plugin 1.0.8 (October 2026)
- Connects to the SDK even when the SDK finished loading before the game started.
- The game is now paused while a reward ad plays.
- A reward ad that was already watched is no longer offered again by mistake. Players can still watch as many reward ads as you offer: each new one fires When reward ad is available.
- Using Display ad before the SDK has loaded no longer causes an error.
Games built with an older plugin or package keep working; switch to the new version the next time you export your game.
Construct 2 integration
A drop-in plugin for the Construct 2 editor. Once installed, ads become event-sheet conditions and actions just like any other plugin.
Prerequisite
Install the WGPlayer Universal Tag
Make sure the WGPlayer Universal Tag is in your game's index.html inside the <head> section.
<!-- WG Universal Tag -->
<script type="text/javascript" async>
!function(e,t){
a=e.createElement("script"),
m=e.getElementsByTagName("script")[0],
a.async=1, a.src=t,
m.parentNode.insertBefore(a,m)
}(document,
"https://universal.wgplayer.com/tag/?lh=" + location.hostname
+ "&wp=" + location.pathname
+ "&ws=" + location.search);
</script>
Download the SDK and extract the folder from the archive to C:\Program Files\Construct 2\exporters\html5\plugins.
Step 1
Add the WeeGoo SDK object
Right-click on Object types and select Insert new object, then double-click on WeeGoo SDK from the Monetisation category.

Step 2
Configure your event sheet
Follow the information in the image below and apply appropriate settings to your game logic.

API reference
Conditions

When the WGSDK is loaded
The WGSDK is loaded — you can safely init a reward or request a midroll. Use the Init rewarded ad action.
When ad starts
The ad is now visible. Pause/mute your game to avoid bad UX and stay compliant with ad policy.
When ad finishes
The ad finished — resume/unmute your game.
When reward ad is available
A reward ad is queued. Show the call-to-action whenever you decide.
When reward ad is granted
The user watched the entire ad and should receive the reward.
When reward ad is canceled
The user didn't watch enough — the reward should not be granted.
When reward was closed
The user closed the reward advertisement — resume/unmute the game.
API reference
Actions

Display ad
Show a midroll ad.
Init rewarded ad
Request a reward ad and queue it for later. When ready, the When reward ad is available condition fires.
Display rewarded ad
Use this when the user clicks the reward ad call-to-action in your game.
About rewarded ads
Test mode vs production
While testing, we use a special test ad unit that returns test ads for every request.
Before publishing your game, contact us with your developer endpoint (site or name) so we can enable production rewarded ads.
Final note
Export settings
When exporting, make sure compression is not set to advanced — that breaks the build.
You can download a demo project to see how actions and conditions are wired up.
Construct 3
Add-on SDKv9New What changed in Add-on SDKv9 (October 2026)
- Connects to the SDK even when the SDK finished loading before the game started.
- A reward ad that was already watched is no longer offered again by mistake. Players can still watch as many reward ads as you offer: each new one fires When reward ad is available.
- When a midroll is refused (for example, requested too soon after the previous one), the game keeps running instead of staying paused.
- Use worker is set to No automatically.
Games built with an older plugin or package keep working; switch to the new version the next time you export your game.
Construct 3 integration
A modern add-on for Construct 3. Install via the Addon Manager, then drop the WeeGooSDK object into your scene and wire up events.
Prerequisite
Install the WGPlayer Universal Tag
Make sure the WGPlayer Universal Tag is in your game's index.html inside the <head> section.
<!-- WG Universal Tag -->
<script type="text/javascript" async>
!function(e,t){
a=e.createElement("script"),
m=e.getElementsByTagName("script")[0],
a.async=1, a.src=t,
m.parentNode.insertBefore(a,m)
}(document,
"https://universal.wgplayer.com/tag/?lh=" + location.hostname
+ "&wp=" + location.pathname
+ "&ws=" + location.search);
</script>
Download the SDK (SDKv9) or download the legacy SDK, then install it via Menu › View › Addon Manager.
Step 1
Add the WeeGooSDK object
In the Project Bar, right-click Object types and select Add new object type, then double-click WeeGoo SDK in the Monetisation category.

Step 2
Configure your events
Follow the image below and apply appropriate settings to your game logic.

API reference
Conditions

When the WGSDK is loaded
The WGSDK is loaded — you can safely init a reward or request a midroll.
When ad starts, pause/mute the game
The ad is now visible. Pause/mute your game to comply with ad policy.
When ad finishes, resume/unmute the game
The ad finished — resume/unmute your game.
When reward ad is available
A reward ad is queued. Show the call-to-action when you're ready.
When reward ad was granted
The user watched the entire ad and should receive the reward.
When reward ad was canceled
The user didn't watch enough — the reward should not be granted.
When reward closed
The user closed the reward advertisement — resume/unmute the game.
API reference
Actions

Display ad
Show a midroll ad.
Init rewarded ad
Request a reward ad and queue it for later. The When reward ad is available condition fires when ready.
Display rewarded ad
Use this when the user clicks the reward ad call-to-action.
About rewarded ads
Test mode vs production
While testing, we use a special test ad unit that returns test ads for every request.
Before publishing, contact us with your developer endpoint to enable production rewarded ads.
Final note
Export settings
The SDKv9 add-on sets Use worker to No for you. With an older add-on, set it yourself in Project properties › Advanced, otherwise ads won't work. When exporting, set Minify mode to None or Simple, not Advanced — Advanced breaks the build.
You can download a demo project to see how actions and conditions are wired up.
JavaScript / HTML5
Universal tagJavaScript / HTML5 · midroll
No SDK for your platform? You can still call midroll ads with the WGPlayer library directly using JavaScript.
Step 1
Add the universal tag
Add the following script to your HTML page:
<script>!function(l){
var b="https://universal.wgplayer.com/tag/?",
p="&wp="+l.pathname+"&ws="+l.search;
function load(h,fb){
var s=document.createElement("script");
s.async=1;
s.fetchPriority="high";
s.src=b+"lh="+h+p;
s.onload=function(){
if(fb&&!window.wgDomainOnboarded)
load("wgplayer.com")
};
s.onerror=function(){
if(fb) load("wgplayer.com")
};
document.head.appendChild(s)
}
load(l.hostname,1)
}(location)</script>
Step 2
Call refetchAd
Request a midroll with the following call:
// Subscribe to midroll callbacks. The WG Universal Tag
// must be in your <head> section before this call.
<script type="text/javascript">
window[window.preroll.config.loaderObjectName]
.refetchAd(RESUME_GAME_CALLBACK);
</script>
Important
Make sure your game is paused/muted before calling refetchAd. This is mandatory to comply with ad policy.
RESUME_GAME_CALLBACK is a function from your game's environment, not a string. It is called when the ad finishes, or right away when the midroll is refused (for example, requested too soon after the previous one). Always resume the game from it.
JavaScript / HTML5 · rewarded
Rewarded ads via the universal tag — no SDK required. Same three callbacks as the native SDKs.
Step 1
Add the universal tag
Same tag as the midroll integration — add it once to your <head> and you're set:
<script>!function(l){
var b="https://universal.wgplayer.com/tag/?",
p="&wp="+l.pathname+"&ws="+l.search;
function load(h,fb){
var s=document.createElement("script");
s.async=1;
s.fetchPriority="high";
s.src=b+"lh="+h+p;
s.onload=function(){
if(fb&&!window.wgDomainOnboarded)
load("wgplayer.com")
};
s.onerror=function(){
if(fb) load("wgplayer.com")
};
document.head.appendChild(s)
}
load(l.hostname,1)
}(location)</script>
Step 2
Register reward callbacks
Subscribe to the three lifecycle callbacks:
// Subscribe to reward callbacks. The WG Universal Tag
// must be in your <head> section before this call.
<script type="text/javascript">
window[window.preroll.config.loaderObjectName]
.registerRewardCallbacks({
onReady: OnReadyMethod, // reward ad ready to display
onSuccess: OnSuccessMethod, // ad finished, grant reward
onFail: OnFailMethod // ad canceled, no reward
});
</script>
Step 3
Show the ad on demand
When onReady fires you know a reward ad is queued. Show it immediately or save it for later:
// Display the rewarded ad any time after onReady has fired
<script type="text/javascript">
window[window.preroll.config.loaderObjectName]
.showRewardAd();
</script>
About rewarded ads
Test mode vs production
While testing and debugging, we use a special test ad unit that returns test ads for every request.
Before publishing your game, contact us with your developer endpoint (site or name) so we can enable production rewarded ads.
Custom splash screen
PrerollMonetize with preroll using a custom splash screen
Serve a full-screen video ad before your game starts and earn on every play. Integrate the WGPlayer Universal Tag, provide a custom splash screen, and bind your Play button to fetchAd — the ad runs first, and your game launches automatically once it completes.
Good to know
Preroll monetization runs on our default splash screen automatically as part of your standard setup — no further work is required. The steps below apply only if you want to provide a custom splash screen for full control over the user interface.
Step 1
Insert the universal tag
Add the WGPlayer Universal Tag to the <head> of every page that hosts a game. It initializes the SDK and exposes the preroll loader on window.
<script>!function(l){
var b="https://universal.wgplayer.com/tag/?",
p="&wp="+l.pathname+"&ws="+l.search;
function load(h,fb){
var s=document.createElement("script");
s.async=1;
s.fetchPriority="high";
s.src=b+"lh="+h+p;
s.onload=function(){
if(fb&&!window.wgDomainOnboarded)
load("wgplayer.com")
};
s.onerror=function(){
if(fb) load("wgplayer.com")
};
document.head.appendChild(s)
}
load(l.hostname,1)
}(location)</script>
Step 2
Design your own splash screen
First, opt out of the default splash preroll. Add the following flag to your page's <head> — without it, our default splash screen runs instead of your custom one.
<script>
// Opt out of the default splash preroll to use your own
window['wgSplashPreroll'] = false;
</script>
Now build the landing view players see before the game begins — your branding, artwork, and a clear call to action. The only requirement is a “Play game” button you can bind to. The visual styling is entirely at your discretion.
<div id="splash">
<h1>My Awesome Game</h1>
<!-- your artwork, branding, etc. -->
<button id="playBtn">Play game</button>
</div>
Step 3
Wire the Play button to the ad
On your “Play game” button, call fetchAd and pass your start-game function as the callback:
window[preroll.config.loaderObjectName].fetchAd( YOUR_START_GAME_CALLBACK_FUNCTION );
Important
The loader is only available once the SDK has booted. Subscribe to the wgSdkReady event on document before reading preroll.config.loaderObjectName or binding the button.
Important
The “Play game” button must have no other event listeners attached to it — only the single click handler you add inside the wgSdkReady callback. Any extra listener on that element can interfere with ad playback and the automatic game start.
Putting it together — wait for the SDK, bind the button inside the handler, and define the callback that loads your game:
// 1. Wait until the WG SDK has booted
document.addEventListener("wgSdkReady", (e) => {
const loader = window[preroll.config.loaderObjectName];
// 2. On the "Play game" button, request the ad
document.getElementById("playBtn").addEventListener("click", () => {
loader.fetchAd(startGame);
});
});
// Called automatically once the ad completes
function startGame() {
// Your game loads here
}
Need a hand? We're here.
Stuck on integration, ready to enable production rewarded ads, or just want a second pair of eyes on your setup? Drop us a line and a real person will get back to you.