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.
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.
import com.topsort.analytics.Analyticsimport com.topsort.analytics.model.PlacementAnalytics.reportRender( resolvedBidId = "<The bid id from the auction winner>", placement = Placement(path = "search_results", position = 1))
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.
An impression records that an ad or product became visible to the shopper.
Analytics.reportImpressionPromoted( resolvedBidId = "<The bid id from the auction winner>", placement = Placement(path = "search_results", position = 1))
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.
A purchase records the products a shopper bought. Topsort attributes it to the ads the shopper interacted with.
import com.topsort.analytics.model.PurchasedItemval item = PurchasedItem( productId = "<Marketplace id for the item>", unitPrice = 1295, quantity = 20)Analytics.reportPurchase( id = "<Marketplace id for the entire purchase>", items = listOf(item),)
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.
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.