Topsort’s Kotlin library enables our clients to easily send auction requests and track events within Android applications.
Minimum requirements: Java 11, Kotlin 2.1, minSdk 24 and compileSdk 36.
Installation
Add the dependency to your build.gradle file:
Setup
Kotlin
UserIdentity.of turns a null or blank id into UserIdentity.Unidentified, in which case the SDK generates an id and keeps it across launches. Pass your own id whenever you have one, logged in or not.
Java
Reporting Events
Renders
A render records that a sponsored ad was inserted into the page, separately from the impression, which records when the ad becomes visible. Renders are sponsored-only, so there is no organic variant.
To report several renders in one event, build them with Render.Factory and pass them to Analytics.reportRenders(list). Render.Factory.build has no defaults for resolvedBidId, placement, occurredAt (an RFC 3339 timestamp), opaqueUserId and id, so pass them for each render, with a unique id.
Impressions
An impression records that an ad or product became visible to the shopper.
For organic results, use Analytics.reportImpressionOrganic with entity = Entity(id = "<product id>", type = EntityType.PRODUCT) instead of resolvedBidId. Import Entity and EntityType from com.topsort.analytics.model: the banner click callback uses a different EntityType.
Clicks
A click records that the shopper clicked an ad or product.
For organic results, use Analytics.reportClickOrganic with an entity, as for impressions.
Purchases
A purchase records the products a shopper bought. Topsort attributes it to the ads the shopper interacted with.
Banner Ads
Add BannerView to your activity XML:
Setup in your activity:
BannerView reports the render as soon as the winner is displayed, the impression once the banner is on screen, and the click when it is tapped. Do not report these events yourself for banners it displays.
For full documentation, see the GitHub repository.