Tracking Guide
You can set up screen tracking programmatically. If the screen is showing a particular item, category, or tag (brand, etc.), consider using one of the following view APIs:
For information on naming the screen and action, see trackAction(String)
.
If you have screen refresh logic, such as "pull to refresh", it's recommended to consider the refreshed screen as a new screen view and call the view/track API there, too. Typically, you can use a single content-loading method for refresh and onStart
or onResume
(your preference), as shown in the following example.
The Personalization Android SDK provides APIs for tracking how the user views and interacts with Articles
, Blogs
, and Products
, collectively called Items
. Personalization understands the possible actions on these items (view, comment, purchase, etc.) and how they relate to each other (categories, brands, keywords, etc.). For a list of available item types, see Item Reference.
The following is an example of how to track an item view using viewItem(Item)
.
The following Item APIs are available. For more information, see Context
.
viewItem(Item)
viewItemDetail(Item)
viewCategory(Category)
viewTag(Tag)
addToCart(LineItem)
purchase(Order)
review(Item)
review(Item, Review)
share(Item)
comment(Item)
favorite(Item)
To process catalog and item data from mobile, you must first enable Process Item Data from Native Mobile Apps in the Personalization UI. This option controls how Personalization processes mobile data about items. By default, Personalization ignores all mobile catalog data.
To enable this option, do the following.
- Log into the Personalization UI.
- Select your Dataset.
- Navigate to Settings > General Setup.
- Under Advanced Options, enable Process Item Data from Native Mobile Apps.
Only enable this option once you have tested against a testing dataset. Perzonalization merges catalog data from mobile and web traffic within a dataset. Therefore, a mobile catalog integration could affect items on the web.
Before you start sending catalog data using APIs like viewItem(Item)
, first send some test events. For guidance on verifying events and actions being sent, see the Testing guide.
Before sending web and mobile data to the same dataset, confirm that the mobile and web items have the same types and IDs. If the item data for web and mobile are the same, you can send item metadata, such as name, URL, image URL, etc., from mobile. First, confirm that the metadata you send from mobile is the same as on the website. Then include the extra data when creating Items
.
To accept this additional data in Personalization, enable the second checkbox Also allow the events to create new items and update existing item metadata when enabling Process Item Data for your dataset.
- For guidance on verifying events and actions being sent, see the
Testing
guide. - For information on custom data campaigns, see Mobile Data Campaigns.