Newer Version Available
Let us know so we can improve!
| Inherits from | Declared in |
|---|---|
NSObject | EVGContext.h |
Provides APIs to handle data campaigns, track item views and activity, and track manual actions, all within a lifecycle-managed context such as EVGScreen.
Typically used as [UIViewController(Evergage) evergageScreen] and, if necessary, [Evergage globalContext].
If this context is currently active or not.
1@property (nonatomic, readonly) BOOL isActiveAvailability
1.2.0
Discussion
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:.
To optionally support custom data campaigns, register a campaign handler for the app-defined target within this context. Can set nil to clear.
1- (void)setCampaignHandler:(nullable EVGCampaignHandler)handler forTarget:(nonnull NSString *)targetParameters
| Parameter | Description |
|---|---|
handler | 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:
For each context and target, only the most recent campaign will be held.
Lifecycle details for an EVGScreen based context:
UIViewController viewWillAppear:.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.viewWillDisappear:), all handlers and held campaigns are cleared.
These limitations and automatic cleanup do not apply to [Evergage globalContext].See Also
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.
1- (void)trackImpression:(nonnull EVGCampaign *)campaignParameters
| Parameter | Description |
|---|---|
campaign | The campaign for which an impression should be tracked. |
See Also
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.
1- (void)trackDismissal:(nonnull EVGCampaign *)campaignParameters
| Parameter | Description |
|---|---|
campaign | The campaign for which a dismissal should be tracked. |
See Also
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.
1- (void)trackClickthrough:(nonnull EVGCampaign *)campaignParameters
| Parameter | Description |
|---|---|
campaign | The campaign for which a clickthrough should be tracked. |
See Also
You do not normally need to call this method. It tracks a click on custom UI you chose to render from a notification received in the foreground.
1- (void)trackClickthrough:(nonnull NSDictionary *)notification actionIdentifier:(nullable NSString *)actionIdentifierParameters
| Parameter | Description |
|---|---|
notification | The notification/userInfo as received from iOS. |
actionIdentifier | 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:
UNNotificationPresentationOptionAlert, Personalization will automatically track any user click.See Also
Tracks that an item is being viewed. Set nil to indicate no longer viewing any item/category/tag.
1- (void)viewItem:(nullable EVGItem *)itemParameters
| 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.
See Also
Same as viewItem: but with a different action name to distinguish this View Item.
1- (void)viewItem:(nullable EVGItem *)item actionName:(nullable NSString *)actionNameParameters
| Parameter | Description |
|---|---|
item | The item being viewed. |
actionName | Optional different action name. |
Availability
1.3.0
Discussion
Only tracks an action if item is non-null.
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 *)itemParameters
| 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.
See Also
Same as viewItemDetail: but with a different action name to distinguish this View Item Detail.
1- (void)viewItemDetail:(nullable EVGItem *)item actionName:(nullable NSString *)actionNameParameters
| Parameter | Description |
|---|---|
item | The item whose details are being viewed. |
actionName | Optional different action name. |
Availability
1.3.0
Discussion
Only tracks an action if item is non-null.
Tracks that a category is being viewed. Set nil to indicate no longer viewing any item/category/tag.
1- (void)viewCategory:(nullable EVGCategory *)categoryParameters
| Parameter | Description |
|---|---|
category | The category being viewed. |
Discussion
Recommended to call just before visible, viewWillAppear for a view controller.
See Also
Same as viewCategory: but with a different action name to distinguish this View Category.
1- (void)viewCategory:(nullable EVGCategory *)category actionName:(nullable NSString *)actionNameParameters
| Parameter | Description |
|---|---|
category | The category being viewed. |
actionName | Optional different action name. |
Availability
1.3.0
Discussion
Only tracks an action if category is non-null.
Tracks that a tag is being viewed. Set nil to indicate no longer viewing any item/category/tag.
1- (void)viewTag:(nullable EVGTag *)tag| Parameter | Description |
|---|---|
tag | The tag being viewed. |
Discussion
Recommended to call just before visible, viewWillAppear for a view controller.
See Also
Same as viewTag: but with a different action name to distinguish this View Tag.
1- (void)viewTag:(nullable EVGTag *)tag actionName:(nullable NSString *)actionName| Parameter | Description |
|---|---|
tag | The tag being viewed. |
actionName | Optional different action name. |
Availability
1.3.0
Discussion
Only tracks an action if tag is non-null.
Tracks that a line item is being added to the shopping cart.
1- (void)addToCart:(nonnull EVGLineItem *)lineItem| Parameter | Description |
|---|---|
lineItem | The line item being added. The [EVGLineItem item] should be an EVGProduct with [EVGProduct price] set. |
Tracks that a line item is being removed from the shopping cart. The [EVGLineItem item] should be an EVGProduct with [EVGProduct price] set.
1- (void)removeFromCart:(nonnull EVGLineItem *)lineItem| Parameter | Description |
|---|---|
lineItem | The line item being removed. |
Availability
1.4.0
Tracks an entire shopping cart, which will update/replace the entire state of the mirrored cart in Personalization.
1- (void)viewCart:(nonnull EVGOrder *)order| Parameter | Description |
|---|---|
order | The entire cart being viewed. Each [EVGLineItem item] should be an EVGProduct with [EVGProduct price] set. |
Discussion
A cart can be considered an “open” order. Most carts will not have an orderId, and so the field can be left un-set.
Tracks that an order was purchased.
1- (void)purchase:(nonnull EVGOrder *)order| Parameter | Description |
|---|---|
order | The order that was purchased. Each [EVGLineItem item] should be an EVGProduct with [EVGProduct price] set. |
Discussion
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.
Tracks that an item was reviewed.
1- (void)review:(nonnull EVGItem *)item| Parameter | Description |
|---|---|
item | The item that was reviewed. |
Tracks that an item was reviewed, as well as the optional details of the review.
1- (void)review:(nonnull EVGItem *)item reviewDetails:(nullable EVGReview *)reviewDetails| Parameter | Description |
|---|---|
item | The item that was reviewed. |
reviewDetails | The optional details of the review, such as the rating. |
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. |
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. |
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. |
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.
Newer Version Available