Appearance
Events
Ad Events
The ad object that you receive from requestAd has the following event handlers. Assign them before you show the ad.
| Handler | Description |
|---|---|
onStart | The ad loaded and the user can start interacting |
onCredit | The user spent at least 30 seconds on the ad and interacted at least once. This is the billing event: the advertiser is billed and you earn your per-unit payment. It yields an engagement |
onFinish | The user reached the end of the ad |
onClose | The ad window closed. It fires independently of onFinish and onCredit, and can fire before onStart if the user closes the window while the ad is still loading. Request a new ad here, so an expired ad is never shown |
onMessage | The ad passes a custom message to your page |
onError | An error occurred with the ad. Treat it as an exception, and remove the ad container |
onClickthrough | A clickthrough happened. It fires only when handle_clickthrough_manually is true. The handler receives the url, and your app decides how to open it |
js
ad.onCredit((engagement) => {
// Send engagement to your server, verify it, then grant the reward
});Engagement Object
The engagement object is passed to the onCredit handler. It tells your page that the user fulfilled the ad requirements and can be rewarded, and it carries the data that your server needs to verify the reward.
| Attribute | Description |
|---|---|
ad | The ad that the user engaged with, including creative_id and currency_amount |
signature | The authentication digest of the engagement |
signature_argument_string | The attributes of the engagement as a query string. The signature is a digest of this value |
key | A unique id of the engagement. It contains alphanumeric characters and ., -, _ |
completed_at | The ISO 8601 date and time when the engagement was completed |
message_id | A unique transaction id, for debugging |
Messages
The onMessage handler receives the following messages:
| Message | Description |
|---|---|
true_targeting_started | TrueX showed the user a TrueTargeting question |
true_targeting_complete | The user completed the TrueTargeting question |
ad_passback | You can ask Infillion to limit the number of consecutive TrueTargeting questions. When the limit is reached, ad_passback fires so you can waterfall to a different ad source |
js
ad.onMessage((payload) => {
if (payload === 'ad_passback') {
// Remove the TrueX ad and waterfall to the next ad source
} else if (payload === 'true_targeting_started') {
// Track that the question started
} else if (payload === 'true_targeting_complete') {
// Track that the question completed
}
});
