Newer Version Available
Let us know so we can improve!
Provides APIs to handle data campaigns, track Item views and interactions, and track manual actions, all within a lifecycle-managed context such as Screen.
1public interface ContextTypically used as Evergage.getScreenForActivity(android.app.Activity), and if necessary, Evergage.getGlobalContext().
| Method | Modifier and Type | Description |
|---|---|---|
addToCart(LineItem lineItem) | void | Tracks that a line item is being added to the shopping cart. |
comment(Item item) | void | Tracks that an item was commented on. |
favorite(Item item) | void | Tracks that an item was marked by the user as a favorite item. |
isActive() | boolean | If this context is currently active or not. |
purchase(Order order) | void | Tracks that an order was purchased. |
review(Item item) | void | Tracks that an item was reviewed, with no additional details. |
review(Item item, Review reviewDetails) | void | Tracks that an item was reviewed, with the contents (optional) of the review. |
setCampaignHandler(CampaignHandler handler, java.lang.String target) | void | To optionally support custom ‘Data’ campaigns, register a campaign handler for the user-defined target within this context. |
share(Item item) | void | Tracks that an item was shared, for instance by email or on a social network. |
trackAction(java.lang.String action) | void | Sends an event to Personalization describing an action to track. |
trackClickthrough(Campaign campaign) | void | Tracks a clickthrough for the provided campaign. |
trackDismissal(Campaign campaign) | void | Tracks a dismissal for the provided campaign. |
trackImpression(Campaign campaign) | void | Tracks an impression for the provided campaign. |
viewCategory(Category category) | void | Tracks that a category is being viewed. |
viewItem(Item item) | void | Tracks that an item is being viewed. |
viewItemDetail(Item item) | void | Tracks that the details of an item are being viewed, such as other product images or a specifications tab. |
viewTag(Tag tag) | void | Tracks that a tag is being viewed. |
1boolean isActive()If this context is currently active or not.
A typical Screen context is active when Screen.isRunning() and the app and user are active.
Besides some initial setup just before becoming visible (setCampaignHandler(com.evergage.android.CampaignHandler, java.lang.String), viewItem(com.evergage.android.promote.Item) etc), activity generally occurs while a context is active. Context activity, in addition to app state and user idleness, can affect campaign delivery. For more information, see setCampaignHandler(com.evergage.android.CampaignHandler, java.lang.String).
Returns
true, if this context is currently active.
1void setCampaignHandler(@Nullable
2 CampaignHandler handler,
3 @NonNull
4 java.lang.String target)To optionally support custom data campaigns, register a campaign handler for the user-defined target within this context. Can set a null handler for a target to clear.
The “target” is an user-defined string that uniquely identifies what the payload data represents and its purpose. See Campaign.getTarget().
While the context, app, and user is active, the handler may receive asynchronous callbacks (on the main thread) with campaigns for the target, in response to actions/events sent. The handler code should show/update the campaign to the user, when appropriate. For example code, see CampaignHandler.
Campaigns may be held for delivery while either:
For each context and target, only the most recent campaign will be held.
Lifecycle details:
onStart().CampaignHandler, a Screen has a limited time to become visible, after which its handlers and held campaigns will be cleared.onStop(), all handlers and held campaigns are cleared.Parameters:
| Parameter | Description |
|---|---|
handler | The campaign handler this context should use for the specified target. |
target | A user-defined string that uniquely identifies what the payload data represents and its purpose. For more information, see Campaign.getTarget(). |
See Also
1void trackImpression(@NonNull
2 Campaign campaign)Tracks an impression for the provided campaign. Call this method after showing the campaign to the user or if the campaign would be shown but the user is in the control group.
Parameters:
| Parameter | Description |
|---|---|
campaign | The campaign for which an impression should be tracked. |
See Also
1void trackClickthrough(Campaign campaign)Tracks a clickthrough for the provided campaign.
Parameters
| Parameter | Description |
|---|---|
campaign | The campaign for which a clickthrough should be tracked. |
See Also
1void trackDismissal(@NonNull
2 Campaign campaign)Tracks a dismissal for the provided campaign.
Parameters
| Parameter | Description |
|---|---|
campaign | The campaign for which a dismissal should be tracked. |
1void viewItem(@Nullable
2 Item item)Tracks that an item is being viewed.
Set null to indicate no longer viewing any item/category/tag.
For an Activity Screen, it is recommended to call this method within onStart() or onResume() before super.onResume(), if the item is known at that time.
Personalization will automatically track the time spent viewing the item while the context, app, and user is active. The item will remain the one viewed until viewItem or viewItemDetail(com.evergage.android.promote.Item) are called again.
Parameters
| Parameter | Description |
|---|---|
item | The item being viewed. |
1void viewItemDetail(@Nullable
2 Item item)Tracks that the details of an item are being viewed, such as other product images or a specifications tab. Set null to indicate no longer viewing any item/category/tag.
For an Activity Screen, it is recommended to call this method within onStart() or onResume() before super.onResume(), if the item is known at that time.
Personalization will automatically track the time spent viewing the item while the context, app, and user is active. The item will remain the one viewed until this method or viewItem(com.evergage.android.promote.Item) are called again.
Parameters
| Parameter | Description |
|---|---|
item | The item whose details are being viewed. |
1void viewCategory(@Nullable
2 Category category)Tracks that a category is being viewed.
Set null to indicate no longer viewing any item/category/tag.
For an Activity Screen, it is recommended to call this method within onStart() or onResume() before super.onResume(), if the category is known at that time.
Parameters
| Parameter | Description |
|---|---|
category | The category being viewed. |
1void viewTag(@Nullable
2 Tag tag)Tracks that a tag is being viewed. Set null to indicate no longer viewing any item/category/tag.
For an Activity Screen, it is recommended to call this method within onStart() or onResume() before super.onResume(), if the tag is known at that time.
Parameters
| Parameter | Description |
|---|---|
tag | The tag being viewed. |
1void addToCart(@NonNull
2 LineItem lineItem)Tracks that a line item is being added to the shopping cart.
Parameters
| Parameter | Description |
|---|---|
lineItem | The line item being added. |
1void purchase(@NonNull
2 Order order)Tracks that an order was purchased. If the order contains no lineItems, the lineItems currently in the cart will be used. If orderId is set and multiple purchase events are received for the same orderId, only the first will be used (all others will be ignored.)
Parameters
| Parameter | Description |
|---|---|
order | The order that was purchased. |
1void review(@NonNull
2 Item item)Tracks that an item was reviewed, with no additional details. Equivalent of calling review(Item, Review) with null for the optional review details.
Parameters
| Parameter | Description |
|---|---|
item | The item that was reviewed. |
1void review(@NonNull
2 Item item,
3 @Nullable
4 Review reviewDetails)Tracks that an item was reviewed, with the contents (optional) of the review.
Parameters
| Parameter | Description |
|---|---|
item | The item that was reviewed. |
reviewDetails | The optional contents of the review, such as the rating. |
1void share(@NonNull
2 Item item)Tracks that an item was shared, for instance by email or on a social network.
Parameters
| Parameter | Description |
|---|---|
item | The item that was shared. |
1void comment(@NonNull
2 Item item)Tracks that an item was commented on. For instance, an article or blog might accept comments.
Parameters
| Parameter | Description |
|---|---|
item | The item that was commented on. |
1void favorite(@NonNull
2 Item item)Tracks that an item was marked by the user as a favorite item. This is an explicit action taken by the user (often indicated by a single star).
Parameters
| Parameter | Description |
|---|---|
item | The item that was marked as favorite. |
1void trackAction(@NonNull
2 java.lang.String action)Sends an event to Personalization describing an action to track. When considering the action name, remember that datasets encompass multiple platforms and apps. The name can match a corresponding action/behavior from another platform/app. A campaign can use a source rule to be limited to a specific source or set of sources. For information on recommended rules, see Mobile Data Campaigns.
Actions sent from this context (including Item APIs) can potentially receive a campaign in response, delivered to a handler via setCampaignHandler(com.evergage.android.CampaignHandler, java.lang.String).
Parameters
| Parameter | Description |
|---|---|
action | A short string that identifies the action. |
Newer Version Available