{"_id":"570eaccb53bfcc0e0037f1fd","parentDoc":null,"category":{"_id":"56af6d6ecc4cbd0d00ce2c88","pages":["56af6e8460a37a0d00ed87ac","56af71e58be2ea0d00b48887","56af73a08be2ea0d00b48890"],"version":"56abbf55f25f160d00e17f51","__v":3,"project":"56abbf55f25f160d00e17f4e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-01T14:36:30.275Z","from_sync":false,"order":2,"slug":"concepts","title":"Kongregate APIs & Concepts"},"user":"56abbec30b9e0b0d00616274","project":"56abbf55f25f160d00e17f4e","__v":5,"version":{"_id":"56abbf55f25f160d00e17f51","project":"56abbf55f25f160d00e17f4e","__v":12,"createdAt":"2016-01-29T19:36:53.665Z","releaseDate":"2016-01-29T19:36:53.665Z","categories":["56abbf56f25f160d00e17f52","56abca6bf9757e0d007c6650","56acddfa0ab3c00d00ce3332","56af65da9d32e30d0006d30f","56af66cab34d210d003d9ad0","56af6afcd21e9c0d00b628d1","56af6d6ecc4cbd0d00ce2c88","5705b12221cfed0e00e8c580","570a5676ade45d0e00c1ad33","570d7d25d1e4b82000d9e385","570eac3c3160d10e0041df0e","575709000fd6a3200010dded"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-04-13T20:32:11.478Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"[block:callout]\n{\n \"type\": \"danger\",\n \"title\": \"Note\",\n \"body\": \"Our Incentivized Ads API has proven to be popular, and unfortunately even a bit too popular - the supply of web ads has not been able to keep up with demand and our ad networks have made it clear that inventory is unlikely to increase in the near future. As a result we are generally suspending adding any new games to the program. We strongly recommend that you design your game without relying on our Ads API as a revenue source.\\n\\nThis feature will not function unless we have enabled it for your game. If you would like to discuss this feature, please email us at [apps:::at:::kongregate.com](mailto:apps@kongregate.com).\"\n}\n[/block]\n## Kongregate Advertising API\n\nKongregate's Advertising API allows you to request and display video ads on demand. The ads should be incentivized with in-game rewards, which can increase both engagement and revenue. Note that these are not \"interstitial\" ads the a player is required to view, but instead should only show when a player requests one.\n\nThe Advertising API is available via the ActionScript 3 and JavaScript interfaces.\n\n### Overview\n\nThe advertising API can be accessed via the `mtx` object on the Kongregate API. Once initialized, events will be generated to notify your application about the availability of advertisements, the state of any ad being displayed, and whether or not in-game rewards should be given.\n\n### Initializing\n\nOnce your game is ready to display ads, you can set up your event listeners for various events and then call `initializeIncentivizedAds`. The `initializeIncentivizedAds` function only needs to be called once.\n\n### Displaying Incentivized Ads\n\nOnce you have received the `adsAvailable` notification, you can call `showIncentivizedAd` to request an incentivized ad. If an ad is successfully displayed, you will receive an `adOpened` event, at which point you should pause gameplay and mute sound until either `adCompleted` or `adAbandoned` is received. Subsequent calls to `showIncentivizedAd` should succeed until the `adsUnavailable` event is fired.\n\n**Example** Initializing incentivized ads and listening for events:\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"kongregate.mtx.addEventListener(\\\"adsAvailable\\\", function(e:Event):void {\\n // Ads are now available, and kongregate.mtx.showIncentivizedAd() will work\\n});\\n\\nkongregate.mtx.addEventListener(\\\"adsUnavailable\\\", function(e:Event):void {\\n // Ads are no longer available, kongregate.mtx.showIncentivizedAd() will fail\\n});\\n\\nkongregate.mtx.addEventListener(\\\"adOpened\\\", function(e:Event):void {\\n // An ad is being displayed\\n});\\n\\nkongregate.mtx.addEventListener(\\\"adCompleted\\\", function(e:Event):void {\\n // An ad has completed successfully, and the player should be rewarded\\n});\\n\\nkongregate.mtx.addEventListener(\\\"adAbandoned\\\", function(e:Event):void {\\n // Ad ad has been closed before completion, the player should not be rewarded\\n});\\n\\nkongregate.mtx.initializeIncentivizedAds();\",\n \"language\": \"haxe\",\n \"name\": \"ActionScript 3\"\n },\n {\n \"code\": \"kongregate.mtx.addEventListener(\\\"adsAvailable\\\", function() {\\n // Ads are now available, and kongregate.mtx.showIncentivizedAd() will work\\n});\\n\\nkongregate.mtx.addEventListener(\\\"adsUnavailable\\\", function() {\\n // Ads are no longer available, kongregate.mtx.showIncentivizedAd() will fail\\n});\\n\\nkongregate.mtx.addEventListener(\\\"adOpened\\\", function() {\\n // An ad is being displayed\\n});\\n\\nkongregate.mtx.addEventListener(\\\"adCompleted\\\", function() {\\n // An ad has completed successfully, and the player should be rewarded\\n});\\n\\nkongregate.mtx.addEventListener(\\\"adAbandoned\\\", function() {\\n // Ad ad has been closed before completion, the player should not be rewarded\\n});\\n\\nkongregate.mtx.initializeIncentivizedAds();\",\n \"language\": \"javascript\"\n }\n ]\n}\n[/block]\nRelated:\n\n* [Mtx.AddEventListener](doc:client-api-mtx-addeventlistener)\n* [Mtx.InitializeIncentivizedAds](doc:client-api-mtx-initializeincentivizedads) \n* [Mtx.ShowIncentivizedAd](doc:client-api-mtx-showincentivizedad)","excerpt":"Add rewarded video advertisements to your game","slug":"api-advertising","type":"basic","title":"Incentivized Ads"}

Incentivized Ads

Add rewarded video advertisements to your game

[block:callout]
{
"type": "danger",
"title": "Note",
"body": "Our Incentivized Ads API has proven to be popular, and unfortunately even a bit too popular - the supply of web ads has not been able to keep up with demand and our ad networks have made it clear that inventory is unlikely to increase in the near future. As a result we are generally suspending adding any new games to the program. We strongly recommend that you design your game without relying on our Ads API as a revenue source.\n\nThis feature will not function unless we have enabled it for your game. If you would like to discuss this feature, please email us at [apps@kongregate.com](mailto:apps@kongregate.com)."
}
[/block]
## Kongregate Advertising API
Kongregate's Advertising API allows you to request and display video ads on demand. The ads should be incentivized with in-game rewards, which can increase both engagement and revenue. Note that these are not "interstitial" ads the a player is required to view, but instead should only show when a player requests one.
The Advertising API is available via the ActionScript 3 and JavaScript interfaces.
### Overview
The advertising API can be accessed via the `mtx` object on the Kongregate API. Once initialized, events will be generated to notify your application about the availability of advertisements, the state of any ad being displayed, and whether or not in-game rewards should be given.
### Initializing
Once your game is ready to display ads, you can set up your event listeners for various events and then call `initializeIncentivizedAds`. The `initializeIncentivizedAds` function only needs to be called once.
### Displaying Incentivized Ads
Once you have received the `adsAvailable` notification, you can call `showIncentivizedAd` to request an incentivized ad. If an ad is successfully displayed, you will receive an `adOpened` event, at which point you should pause gameplay and mute sound until either `adCompleted` or `adAbandoned` is received. Subsequent calls to `showIncentivizedAd` should succeed until the `adsUnavailable` event is fired.
**Example** Initializing incentivized ads and listening for events:
[block:code]
{
"codes": [
{
"code": "kongregate.mtx.addEventListener(\"adsAvailable\", function(e:Event):void {\n // Ads are now available, and kongregate.mtx.showIncentivizedAd() will work\n});\n\nkongregate.mtx.addEventListener(\"adsUnavailable\", function(e:Event):void {\n // Ads are no longer available, kongregate.mtx.showIncentivizedAd() will fail\n});\n\nkongregate.mtx.addEventListener(\"adOpened\", function(e:Event):void {\n // An ad is being displayed\n});\n\nkongregate.mtx.addEventListener(\"adCompleted\", function(e:Event):void {\n // An ad has completed successfully, and the player should be rewarded\n});\n\nkongregate.mtx.addEventListener(\"adAbandoned\", function(e:Event):void {\n // Ad ad has been closed before completion, the player should not be rewarded\n});\n\nkongregate.mtx.initializeIncentivizedAds();",
"language": "haxe",
"name": "ActionScript 3"
},
{
"code": "kongregate.mtx.addEventListener(\"adsAvailable\", function() {\n // Ads are now available, and kongregate.mtx.showIncentivizedAd() will work\n});\n\nkongregate.mtx.addEventListener(\"adsUnavailable\", function() {\n // Ads are no longer available, kongregate.mtx.showIncentivizedAd() will fail\n});\n\nkongregate.mtx.addEventListener(\"adOpened\", function() {\n // An ad is being displayed\n});\n\nkongregate.mtx.addEventListener(\"adCompleted\", function() {\n // An ad has completed successfully, and the player should be rewarded\n});\n\nkongregate.mtx.addEventListener(\"adAbandoned\", function() {\n // Ad ad has been closed before completion, the player should not be rewarded\n});\n\nkongregate.mtx.initializeIncentivizedAds();",
"language": "javascript"
}
]
}
[/block]
Related:
* [Mtx.AddEventListener](doc:client-api-mtx-addeventlistener)
* [Mtx.InitializeIncentivizedAds](doc:client-api-mtx-initializeincentivizedads)
* [Mtx.ShowIncentivizedAd](doc:client-api-mtx-showincentivizedad)