Skip to content

Events ​

Ad Events ​

The ad object that you receive from requestAd has the following event handlers. Assign them before you show the ad.

HandlerDescription
onStartThe ad loaded and the user can start interacting
onCreditThe 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
onFinishThe user reached the end of the ad
onCloseThe 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
onMessageThe ad passes a custom message to your page
onErrorAn error occurred with the ad. Treat it as an exception, and remove the ad container
onClickthroughA 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.

AttributeDescription
adThe ad that the user engaged with, including creative_id and currency_amount
signatureThe authentication digest of the engagement
signature_argument_stringThe attributes of the engagement as a query string. The signature is a digest of this value
keyA unique id of the engagement. It contains alphanumeric characters and ., -, _
completed_atThe ISO 8601 date and time when the engagement was completed
message_idA unique transaction id, for debugging

Messages ​

The onMessage handler receives the following messages:

MessageDescription
true_targeting_startedTrueX showed the user a TrueTargeting question
true_targeting_completeThe user completed the TrueTargeting question
ad_passbackYou 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
  }
});

Integration documentation for Infillion Ads