{"_id":"57115eae3590a50e00bba919","user":"56abbec30b9e0b0d00616274","__v":2,"parentDoc":null,"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"},"category":{"_id":"570a5676ade45d0e00c1ad33","__v":0,"project":"56abbf55f25f160d00e17f4e","version":"56abbf55f25f160d00e17f51","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-04-10T13:34:46.864Z","from_sync":false,"order":3,"slug":"client-side-api","title":"Client Side API"},"project":"56abbf55f25f160d00e17f4e","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-04-15T21:35:42.909Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":true,"order":6,"body":"### Mtx events\n\nThis method can be used to listen for events related to the [incentivized advertising API](doc:api-advertising) \n\nThe `addEventListener` method takes two arguments, the event type, and a callback function:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`event_type`\",\n    \"0-1\": \"String\",\n    \"0-2\": \"Type of event to listen for\",\n    \"1-0\": \"`callback`\",\n    \"1-1\": \"Function\",\n    \"1-2\": \"Function to call when the event is triggered\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\n### Incentivized ad events\n\nThe following event types are currently supported:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`adsAvailable`\",\n    \"0-1\": \"Ads are now available, and `showIncentivizedAd` will work\",\n    \"0-2\": \"The username of the user who sent the message (will always be the current user)\",\n    \"1-0\": \"`adsUnavailable`\",\n    \"1-1\": \"Ads are not available, and `showIncentivizedAd` will fail\",\n    \"1-2\": \"The message content\",\n    \"2-0\": \"`adOpened`\",\n    \"2-1\": \"An ad is being displayed\",\n    \"3-0\": \"`adCompleted`\",\n    \"3-1\": \"An ad has completed successfully, and the player should be rewarded\",\n    \"4-0\": \"`adAbandoned`\",\n    \"4-1\": \"Ad ad has been closed before completion, the player should not be rewarded\"\n  },\n  \"cols\": 2,\n  \"rows\": 5\n}\n[/block]\nRelated:\n\n* [Advertising API Overview](doc:api-advertising) \n* [Mtx.InitializeIncentivizedAds](doc:client-api-mtx-initializeincentivizedads) \n* [Mtx.ShowIncentivizedAd](doc:client-api-mtx-showincentivizedad)","excerpt":"`addEventListener(event_type, callback)`","slug":"client-api-mtx-addeventlistener","type":"fn","title":"Mtx.AddEventListener"}

Mtx.AddEventListener

`addEventListener(event_type, callback)`

### Mtx events This method can be used to listen for events related to the [incentivized advertising API](doc:api-advertising) The `addEventListener` method takes two arguments, the event type, and a callback function: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "`event_type`", "0-1": "String", "0-2": "Type of event to listen for", "1-0": "`callback`", "1-1": "Function", "1-2": "Function to call when the event is triggered" }, "cols": 3, "rows": 2 } [/block] ### Incentivized ad events The following event types are currently supported: [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Description", "0-0": "`adsAvailable`", "0-1": "Ads are now available, and `showIncentivizedAd` will work", "0-2": "The username of the user who sent the message (will always be the current user)", "1-0": "`adsUnavailable`", "1-1": "Ads are not available, and `showIncentivizedAd` will fail", "1-2": "The message content", "2-0": "`adOpened`", "2-1": "An ad is being displayed", "3-0": "`adCompleted`", "3-1": "An ad has completed successfully, and the player should be rewarded", "4-0": "`adAbandoned`", "4-1": "Ad ad has been closed before completion, the player should not be rewarded" }, "cols": 2, "rows": 5 } [/block] Related: * [Advertising API Overview](doc:api-advertising) * [Mtx.InitializeIncentivizedAds](doc:client-api-mtx-initializeincentivizedads) * [Mtx.ShowIncentivizedAd](doc:client-api-mtx-showincentivizedad)