⚡ Zero-Config Ad Placement API✓ Auto-Injected on UploadđŸ•šī¸ Google AdSense H5 Compatible

Monetizing Uploaded Games on EEND

Every HTML5 game uploaded to EEND Games (from Godot, Unity WebGL, Phaser, Construct, or custom Canvas engines) is automatically connected to the EEND Ads Bridge. Call window.adBreak() or window.EENDGames.showRewarded() to show non-intrusive commercial breaks and rewarded perk bonuses.

Interactive SDK Simulator & Live Event Inspector

Test modals & inspect simulated game lifecycle in real time

1. Click to trigger simulated ad requests:

💡 How it works behind the scenes:

1. The game posts an EEND_AD_REQUEST event to the parent page.

2. Parent page displays the high-converting modal and mutes game audio.

3. On completion, parent returns EEND_AD_RESPONSE with status: 'rewarded'.

Live Event Console
đŸŸĸ [00:00:00] EEND Games Ads Bridge initialized.
⚡ [00:00:00] Ready to receive adBreak() or EENDGames.showRewarded() calls.

How Hosting & Auto-Injection Works

01

Upload Any ZIP

Export your game to HTML5 from Godot, Unity, Phaser, or any engine. Zip your build folder and upload it in the admin portal.

02

Zero-Config Injection

When players launch your game via /api/games/hosted/[slug], our proxy automatically injects <script src="/api/games/ads-bridge.js"> before </head>.

03

Universal Standard

Your game can call standard Google H5 adBreak() or EENDGames.showRewarded(). Everything works automatically without boilerplate.

Google H5 Games Ad Placement API Checklist

To serve official Google AdSense H5 video ads, commercial breaks, and banner units across your games, follow this setup:

Step 1: AdSense Approval

AdSense Account & Domain

  • Have an active Google AdSense account (adsense.google.com).
  • Verify your domain under Sites in AdSense.
  • Under Ads for Games, activate the Ad Placement API (H5 Games Ads).
Step 2: Publisher ID (.env.local)

Configure Environment Variable

Copy your Publisher ID (starts with ca-pub-) into your .env.local file:

NEXT_PUBLIC_ADSENSE_CLIENT_ID=ca-pub-XXXXXXXXXXXXXXXX
Step 3: Test Mode Flag

Safe Testing during Development

While developing locally or before going live, Google provides data-adbreak-test="on" which is automatically set in dev mode. This lets you test video ad breaks without violating Google policies.

Step 4: Ad Frequency Hint

User Experience & Timing

Google requires data-ad-frequency-hint="30s"on the script tag (already configured in our root layout). Commercial breaks are automatically throttled so players aren't spammed with ads.

Engine Integration Guides & Code Templates

Select your game engine to copy ready-to-use scripts

Godot 4 & 3 Autoload Singleton (`AdsManager.gd`)

Save as AdsManager.gd and add as an Autoload in Project Settings → Globals → Autoload.

# ==============================================================================
# AdsManager.gd (Godot 4 & Godot 3 Autoload Singleton)
# Works out of the box when your game is uploaded to EEND Games.
# The EEND Ads Bridge is auto-injected into your hosted index.html!
# ==============================================================================
extends Node

signal reward_granted(reward_name)
signal ad_completed()
signal ad_dismissed()

func _ready():
	process_mode = Node.PROCESS_MODE_ALWAYS
	print("[AdsManager] Ready on EEND Games Portal")

# 1. Show Commercial Break / Interstitial Ad
func show_interstitial(ad_name: String = "game_break") -> void:
	if not OS.has_feature("web"):
		print("[AdsManager] Non-web platform: skipping interstitial.")
		emit_signal("ad_completed")
		return
		
	mute_audio(true)
	
	# Godot 4.x uses JavaScriptBridge; Godot 3.x uses JavaScript
	var js_code = """
	if (window.adBreak) {
		window.adBreak({
			type: 'start',
			name: '%s',
			beforeAd: () => {},
			afterAd: () => { window.__godot_ad_done && window.__godot_ad_done(); }
		});
	} else if (window.EENDGames) {
		window.EENDGames.showInterstitial({ name: '%s' });
	}
	""" % [ad_name, ad_name]
	
	_eval_js(js_code)
	mute_audio(false)
	emit_signal("ad_completed")

# 2. Show Rewarded Ad (Revive player, double coins, unlock skins)
func show_rewarded(reward_name: String = "+100 Coins", callback: Callable = Callable()) -> void:
	if not OS.has_feature("web"):
		print("[AdsManager] Non-web platform: granting test reward.")
		if callback.is_valid():
			callback.call(true)
		emit_signal("reward_granted", reward_name)
		return

	mute_audio(true)
	
	# Execute rewarded call with Google adBreak / EEND SDK
	var js_code = """
	if (window.EENDGames) {
		window.EENDGames.showRewarded({
			name: 'reward_ad',
			rewardLabel: '%s',
			onReward: () => {
				console.log('[Godot] Rewarded perk granted: %s');
			}
		});
	}
	""" % [reward_name, reward_name]
	
	_eval_js(js_code)
	mute_audio(false)

func mute_audio(is_muted: bool) -> void:
	# Mute Master Audio bus during commercial breaks
	var master_bus = AudioServer.get_bus_index("Master")
	if master_bus >= 0:
		AudioServer.set_bus_mute(master_bus, is_muted)

func _eval_js(code: String):
	# Safe cross-version web bridge
	if ClassDB.class_exists("JavaScriptBridge"):
		# Godot 4
		return JavaScriptBridge.eval(code)
	elif ClassDB.class_exists("JavaScript"):
		# Godot 3
		return ClassDB.instantiate("JavaScript").eval(code)

API Quick Reference

FunctionParametersDescription
window.adBreak(params){ type: 'start'|'reward', name, beforeAd, afterAd, ... }Standard Google H5 Games Ad Placement API method. Supported universally.
window.EENDGames.showInterstitial(opts){ name, beforeAd, afterAd, adBreakDone }Shows commercial break. Returns Promise<boolean> that resolves true once viewed.
window.EENDGames.showRewarded(opts){ name, rewardLabel, onReward, onDismiss, ... }Shows rewarded video ad. Calls onReward() only if the player completes the ad without forfeiting.
window.EENDGames.requestReward(label)label: string (e.g. "+100 Gold")Async helper. Returns await EENDGames.requestReward(...) resolving true if reward granted.
window.addEventListener('eend:pause', fn)CustomEvent('eend:pause')Fired right before any ad modal opens. Use to mute Web Audio contexts and pause high-rate game loops.
window.addEventListener('eend:resume', fn)CustomEvent('eend:resume')Fired immediately when the ad modal closes. Use to resume audio and gameplay loops.

Want to Test Offline or on Localhost?

You can download the standalone bridge script or link directly to /js/eend-game-ads.js during local testing. When running standalone without an iframe parent, the bridge automatically opens interactive simulation dialogs so you can verify your game logic offline!