Impression Tracking on

Impression Tracking

Button SDK impression tracking works by adding an ImpressionView as a subview to the views that you use to display offers to your users. Impression views are transparent and do not accept user interaction. They are used strictly to detect the visibility of the offer and track "viewable impressions" as users interact with your app.

This feature will be tracking what are known as “viewable impressions” as defined by the Interactive Advertising Bureau (IAB), where a viewable impression is one that meets the following criteria:

  • Pixel Requirement: Greater than or equal to 50% of the pixels (Density- Independent) in the offer were on an in-focus browser or a fully downloaded, opened, initialized application, on the viewable space of the device.
  • Time Requirement: The time the pixel requirement is met was greater than or equal to one continuous second, post offer render. The clock starts once the pixel requirement is met.
  • User Interaction: A strong user interaction with the offer can substitute the above requirements (i.e. a tap on the offer).

In this guide, we'll go over:

Adding Impression Views

Impression tracking illustration

You add impression views to your app's offer views just as you would add any other view. You can add them with a few lines of code in Interface Builder.

When you create an impression view, you specify a "creative type" to indicate where in your app an impression originated. The ImpressionView class exposes creativeType as an enumerated type in code, but it can be specified as a string in your layout or in Interface Builder.

Available Creative Types

  • hero
  • carousel
  • list
  • grid
  • detail
  • other

In View Layout

In Interface Builder, you can add impression views and set the creativeType in the Attributes Inspector for the ImpressionView.

Setting creative type


let impressionView = ImpressionView(creativeType: .hero)
BTNImpressionView *impressionView = [[BTNImpressionView alloc] initWithCreativeType:BTNCreativeTypeHero];
[myOfferView addSubview:impressionView];

Tracking Offer Details

When you populate your offer views with data you’re displaying to the user, call track(…) on the ImpressionView that you added to that view in the previous step.

The track(…) method takes the following arguments:

  • url (string): The same URL you’ll use when fetching a Purchase Path from the Button SDK.
  • visibleRateType (enum): the rate type displayed to your user. Accepted values are "percent" or "fixed".
  • visibleRate (double): the visible rate displayed to your user, e.g. "5" to represent an offer of 5%.
  • offerId (string): If you’re using Button’s Personalized Rates API, the offers[].id associated with the offer. In the case of a Brand with multiple categories/rates, please use the best_offer_id value. If you are not using the Rates API, do not include this value in the track(…) method.
// Track the new data on the associated ImpressionView
myOfferView.impressionView.track(withURL: URL(string: "")! // The URL for the Brand offer,
                                 visibleRateType: .percent, // or .fixed (a percentage or fixed rate offer)
                                 visibleRate: 5, // The rate visible to the user on your offer view. In this example, it's a 5% offer.
                                 offerId: "offer-abc123def456abc1") // Only relevant if using Button's Personalized Rates API. If not, pass `nil` here.
// Track the new data on the associated ImpressionView
[impressionView trackWithURL:[NSURL URLWithString:@""], // The URL for the Brand offer,
             visibleRateType:BTNVisibleRateTypePercent, // or BTNVisibleRateTypeFixed (a percentage or fixed rate offer)
                 visibleRate:5, // The rate visible to the user on your offer view. In this example, it's a 5% offer.
                     offerId:@"offer-abc123def456abc1"]; // Only relevant if using Button's Personalized Rates API. If not, pass `nil` here.