Provides APIs to handle data campaigns, track item views and activity, and track manual actions, all within a lifecycle-managed context such as EVGScreen.
A typical EVGScreen context is active when the screen is visible and the app is not backgrounded.
Besides some initial setup just before becoming visible or active (setCampaignHandler:forTarget:, viewItem: 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:forTarget:.
Campaigns and Stats
setCampaignHandler:forTarget:
To optionally support custom data campaigns, register a campaign handler for the app-defined target within this context. Can set nil to clear.
The campaign handler this context should use for the specified target.
target
App-defined string that uniquely identifies the payload data schema - what the data represents and its purpose. For more information, see [EVGCampaign target].
Discussion
Campaigns can potentially be received in response to actions (see trackAction:) and item interactions (see viewItem:) tracked on this context.
The target is an app-defined string that uniquely identifies the payload data schema - what the data represents and its purpose. For more information, see [EVGCampaign target].
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, and follow best practices using weak references. For example code, see EVGCampaignHandler.
Campaigns may be held for delivery while either:
The context, app, or user is inactive
No handler is found for the campaign’s target within this context
For each context and target, only the most recent campaign will be held.
Lifecycle details for an EVGScreen based context:
We recommend to always call this method just before becoming visible, specifically UIViewController viewWillAppear:.
In order to prevent accidental leaks in the handler block (see weak references in EVGCampaignHandler example code to prevent this), a screen has a limited time to become visible, after which its handlers and held campaigns will be cleared.
When a screen transitions to not visible (viewWillDisappear:), all handlers and held campaigns are cleared.
These limitations and automatic cleanup do not apply to [Evergage globalContext].
Tracks an impression for the provided campaign. Call this method after showing the campaign to the user or after the campaign would be shown but the user is in the control group. For more information, see Mobile Data Campaigns and EVGCampaignHandler.
Tracks a dismissal for the provided campaign. Call this method after showing the campaign to the user and the user dismissed the campaign. For more information, see Mobile Data Campaigns and EVGCampaignHandler.
Tracks a clickthrough for the provided data campaign. Call this method after showing the campaign to the user and the user clicked campaign content. For more information, see Mobile Data Campaigns and EVGCampaignHandler.
The actionIdentifier from the notification, if any.
Availability
1.3.0
Discussion
Personalization automatically tracks clicks on push notifications. However, when the notification is received while the app is in the foreground, the notification is not automatically shown to the user. If you are using UNUserNotificationDelegate, you have some options with userNotificationCenter:willPresentNotification:withCompletionHandler:
If you don’t show anything to the user, there is no click to track.
If you show the notification with UNNotificationPresentationOptionAlert, Personalization will automatically track any user click.
If you don’t show the notification, but instead render some other UI based on the notification, and want to track user clicks, call this method when the user clicks on the associated UI.
Tracks that an item is being viewed. Set nil to indicate no longer viewing any item/category/tag.
1- (void)viewItem:(nullable EVGItem *)item
Parameters
Parameter
Description
item
The item being viewed.
Discussion
Recommended to call just before visible, viewWillAppear for a view controller.
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 viewItemDetail: are called again.
Tracks that the details of an item are being viewed, such as viewing other product images or a specifications tab. Set nil to indicate no longer viewing any item/category/tag.
1- (void)viewItemDetail:(nullable EVGItem *)item
Parameters
Parameter
Description
item
The item whose details are being viewed.
Discussion
Recommended to call just before visible, viewWillAppear for a view controller.
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: are called again.
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, all but the first will be ignored.
review:
Tracks that an item was reviewed.
1- (void)review:(nonnull EVGItem *)item
Parameter
Description
item
The item that was reviewed.
review:reviewDetails:
Tracks that an item was reviewed, as well as the optional details of the review.
The optional details of the review, such as the rating.
share:
Tracks that an item was shared, for instance by email or on a social network.
1- (void)share:(nonnull EVGItem *)item
Parameter
Description
item
The item that was shared.
comment:
Tracks that an item was commented on. For instance, an article or blog might accept comments.
1- (void)comment:(nonnull EVGItem *)item
Parameter
Description
item
The item that was commented on.
favorite:
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).
1- (void)favorite:(nonnull EVGItem *)item
Parameter
Description
item
The item that was marked as favorite.
Manually Tracking Actions
trackAction:
Sends an event to Personalization describing an action to track.
1- (void)trackAction:(nonnull NSString *)action
Parameter
Description
action
A short string that identifies the action.
Discussion
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 recommeneded rules, see Mobile Data Campaigns.