Get started
Publish your web game on GOOF and earn from rewarded ads, interstitials and in-app purchases. You add one script, test on your own machine, then upload a build.
What you need
- A web game: plain HTML5, three.js, Unity WebGL, Cocos Web Mobile or any other engine that builds to a web page.
- A GOOF developer account. Sign in with Google or an email.
- An
index.htmlat the root of your build.
The steps
- Create a game in your dashboard. You get an app id (it starts with
d) and a server secret. The secret is shown once, so keep it somewhere safe. - Add the SDK script to your page and call
GOOF.game.init(). - Create ad units and products for your game in the Monetization tab.
- Test on your machine. On localhost the SDK runs a mock host with test ads and a test payment sheet.
- Upload a build, try it in the test player, then submit it for review.
Add the SDK
Put this tag in your index.html, before your game code:
<script src="https://developer.goof.gg/sdk/v1/goof.js"></script>
It defines window.GOOF. It has no dependency and also loads as a module.
Start the SDK
const info = await GOOF.game.init({ gameId: 'dYOUR_APP_ID' });
console.log(info.host); // "android", "ios", "web", "mock" or "none"
console.log(info.can.rewarded); // what this host supports
// When your first screen is ready:
GOOF.game.setLoadingProgress(1);
GOOF.game.gameReady();
GOOF.game.init() is safe to call more than once. Every other call waits for it by itself, so you can also skip it.
Your first rewarded ad
const { rewarded } = await GOOF.ads.showRewarded({ adUnitId: 'au_0123456789ab' });
if (rewarded) giveExtraLife();
This promise never rejects. See Ads for the full ad object with events.
Test locally
When no GOOF host answers within one second, the SDK picks a host:
- mock on
localhost,127.0.0.1, afile:page, with?goof_mock=1in the address, or withGOOF.game.init({ mock: true }). You get a full screen test ad with a 5 second countdown and a test payment sheet. Products and storage live in localStorage. Any ad unit id is accepted. - none anywhere else. Ads and payments then fail with error
40001(not supported on this host).
You can also run a build in the simulator.
Next
- Engine guides: three.js, Unity, Cocos.
- Ads and in-app purchases.
- Publishing and review.