Tracking

You can set up screen tracking either programmatically or by uploading screens and then dynamically mapping (and later remapping) them to named actions.

For information on naming screens and actions, see [EVGContext trackAction:].

If the screen is showing a particular item, category, or tag (brand, etc.), consider using [EVGContext viewItem:], [EVGContext viewCategory:], or [EVGContext viewTag:]. Otherwise, you can use [EVGContext trackAction:].

If you have screen refresh logic, such as "pull to refresh", it's recommended to consider it as a new screen view and call the view/track API there. Typically, you can use a single content-loading method for screen refreshes and a viewWillAppear or viewDidAppear (your preference).

The following code samples depict how you can set up screen tracking programmatically.

  • Objective-C

  • Swift

You can also dynamically map (and remap) screens to actions by uploading screen information to Marketing Cloud Personalization and simply naming the screens in the Personalization UI.

To upload screen information to Personalization, do the following.

  1. In the Personalization UI, select the Dataset.
  2. From the left-hand menu, select Mobile > your app.
  3. Select Detect New Screens.
  4. Launch your app in DEBUG mode with [EVGClientConfigurationBuilder useDesignMode] enabled.
  5. Hold down three fingers on the screen in the app for 5 seconds. If you are in the simulator, hold the Alt or Option key and the left mouse button for 5 seconds instead. You should see a dialog confirming you are connected to the Personalization Designer. If Wi-Fi is not detected, you should be prompted whether you wish to proceed or not.
  6. Once connected, navigate through the screens of your app. Screen images and metadata are uploaded to Personalization as you navigate through the screens.

After uploading screens, you can set the action for a screen by doing the following.

  1. Return to your mobile app in the Personalization UI by selecting your Dataset.
  2. On the left-hand menu, select Mobile > your app.
  3. In the Untracked section, select a screen.
  4. Type an Action Name.
  5. Select Update Action.
  6. To see or change screens with actions, explore the Tracked section.

When you are done, stop the app or put it in the background to leave design mode. The next time the app is launched or brought to the foreground, it will fetch new configuration and then start sending actions matching the screens as you navigate through them. You can confirm this in the Event Viewer, as described in the Testing guide.

These steps only allow you to map a simple action like [EVGContext trackAction:]. To map item and catalog interactions, you must still use APIs like [EVGContext viewItem:], [EVGContext viewCategory:], etc.

The Personalization iOS SDK provides APIs for tracking how the user views and interacts with Products, Articles, and Blogs (collectively called Items). Personalization understands the actions that are possible on these items (view, comment, purchase, etc.) and also how they relate to each other (categories, brands, keywords, etc.).

For more information on available item types, see Item Reference.

The following code samples depict how to track an item view using [EVGContext viewItem:].

  • Objective-C

  • Swift

The following Item APIs are available.

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.

To enable this setting, do the following.

  1. Select the Dataset from the Personalization UI.
  2. Click Settings > General Setup.
  3. Under Advanced Options, enable Process Item Data from Native Mobile Apps.

Do not enable this option until you've tested against a test dataset. Since Personalization merges catalog data from mobile and web traffic within a dataset, a mobile catalog integration could affect items on the web.

To start sending catalog data using APIs like [EVGContext viewItem:], first send some test events. For more information on verifying these test events, 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 EVGItems. To accept this additional data in Personalization, enable the second checkbox Also allow the events to create new items and update existing item metadata.