Testing

This article takes you through the following.

  • Verifying events and actions your app sends to Marketing Cloud Personalization.
  • Testing mobile data campaigns
  • Troubleshooting campaigns
  • Testing campaign URLs on your mobile device

Verifying Events and Actions

The Event Stream on the Personalization UI enables you to verify the events and actions your app sends to Personalization.

To check the incoming event stream, do the following.

  1. Log in to the Personalization UI and select the Dataset.
  2. From the left-hand menu, click Reports > Event Stream.
  3. Set the Event Type filter to Mobile and look for actions sent by the app.

Note

If you followed the steps in the Tracking guide and are still not seeing any mobile events appear in the specified dataset, get assistance by logging a support ticket.

Testing Campaigns

You’re ready to test your mobile campaigns once you’ve completed the following, as described in the Mobile Data Campaigns and Tracking guides.

To test your campaign, put a breakpoint in your campaign handler, and navigate to the screen with that campaign handler and action/event.

When testing your mobile campaigns, consider the following.

  • If you are testing or integrating on a non-production dataset, consider setting the campaign to Published. As long as the rules are easy to fulfill, you can use the app as a user would.
  • If you are on a production dataset, you should set the campaign to Testing and enter test URLs in the mobile browser on the device. For more information on test URLs, see Test URLs on Device.

To test your mobile campaign, put a breakpoint in your campaign handler and navigate to the screen with that campaign handler and action/event.

Campaign Troubleshooting

If your campaign handler is not getting called, there are a few things to troubleshoot:

  • The campaign should typically include at least one rule, typically action-based (see [EVGContext trackAction:]) or item-based (see [EVGContext viewItem:]). Ensure the context is tracking an action or interaction that fulfills the rule.
  • On the same context ([UIViewController(Evergage) evergageScreen] or less commonly [Evergage globalContext]), before tracking the action/interaction, ensure [EVGContext setCampaignHandler:forTarget:] is called.
  • Make sure the target defined in the mobile data campaign in the Personalization UI corresponds to the target used in [EVGContext setCampaignHandler:forTarget:]. It is case-sensitive.
  • Ensure any campaign rules are reasonable and being fulfilled.
  • If the campaign is unpublished, use Test URLs in the mobile browser on the device.
  • Ensure the campaign’s key/value pairs have valid formats, and provide fallback or default values as desired. If a value cannot be determined, the campaign will not be sent. If using a recipe for recommendations, test that the recipe is providing results.
  • Consider temporarily using simpler or static key/value pairs.
  • Consider temporarily removing or loosening campaign rules.

Also worth checking:

  • You may want the campaign control percentage to be 0% while testing. The default is 10%.
  • Make sure the key(s) defined in the campaign match the key(s) the campaign handler expects.

Note

If you’ve followed these steps and are still having issues with your campaign, please log a support ticket.

Test URLs on Device

The scene-based URL forwarding and alert behavior described here requires SDK 1.5.1 or a later version containing these fixes. SDK 1.5.1 requires iOS 15.0 or later. SDK 1.5.0 can ignore manually forwarded URLs when swizzling is enabled, and its legacy alerts are incompatible with scene-based apps. Migrating the app or disabling swizzling alone does not restore these preview flows.

To manage test campaigns from the device, open campaign-related URLs in the mobile browser after configuring the app’s URL scheme and URL forwarding. Your app must satisfy the following conditions.

Test URLs can enable all test campaigns, a specific experience, or disable testing. For information on test URL formats, see [Evergage(Swizzling) handleOpenURL:].

To start testing, once the Personalization-integrated app is on the device, open Safari on a mobile device and enter a test URL. The app should launch and you should see a confirmation message appear.

You can also find generated test URLs in the Personalization UI. Under Campaigns, select the mobile campaign you want to test. These URLs are:

  • Based on the app’s Personalization AppID. On opening these URLs they will redirect to URLs based on the app’s Personalization URL Scheme, as defined in [Evergage(Swizzling) handleOpenURL:].
  • Generated using the Personalization AppID of the first app used in a Campaign Source Rule or the AppID of the first enabled app found.

Register Personalization URL Scheme

To register the Personalization URL scheme, do the following.

  1. Under the Info tab, add a URL Type in your app target.
  2. Under URL Schemes, enter the URL scheme from the Personalization UI. (Select Dataset, navigate from the left-hand menu Mobile > (this app), scroll down to see the app’s URL Scheme (format “evgxxxxx”))
  3. Under Identifier, enter BundleID.evgscheme, where BundleID is the app’s Bundle ID, as found in Personalization UI. (Select Dataset, Mobile > this app) and in Xcode app Target: (General > Bundle Identifier). For example, if the app’s Bundle ID is com.company.app, then the Identifier should be com.company.app.evgscheme.

Forward Test URLs in a Scene-Based App

Forward each URL to [Evergage(Swizzling) handleOpenURL:] in both scene:willConnectToSession:options: (cold launch or a newly connected scene) and scene:openURLContexts: (an already connected scene). Scene apps must forward URLs explicitly whether EvergageSwizzlingEnabled is YES or NO. The SDK does not swizzle scene delegates. SDK startup stays in AppDelegate. These callbacks do not replace your existing window setup.

Objective-C — add to a SceneDelegate implementation:

@import Evergage;
@import Evergage.Swizzling;

- (void)scene:(UIScene *)scene
    willConnectToSession:(UISceneSession *)session
                 options:(UISceneConnectionOptions *)options {
    // Keep your existing window / root-view-controller setup here.
    for (UIOpenURLContext *context in options.URLContexts) {
        [[Evergage sharedInstance] handleOpenURL:context.URL];
    }
}

- (void)scene:(UIScene *)scene
    openURLContexts:(NSSet<UIOpenURLContext *> *)contexts {
    for (UIOpenURLContext *context in contexts) {
        [[Evergage sharedInstance] handleOpenURL:context.URL];
    }
}

Swift — add to a SceneDelegate implementation:

import Evergage
import Evergage.Swizzling

func scene(
    _ scene: UIScene,
    willConnectTo session: UISceneSession,
    options connectionOptions: UIScene.ConnectionOptions
) {
    // Keep your existing window / root-view-controller setup here.
    for context in connectionOptions.urlContexts {
        _ = Evergage.sharedInstance().handleOpen(context.url)
    }
}

func scene(_ scene: UIScene, openURLContexts contexts: Set<UIOpenURLContext>) {
    for context in contexts {
        _ = Evergage.sharedInstance().handleOpen(context.url)
    }
}

SwiftUI — forward URLs from the WindowGroup content:

import Evergage
import Evergage.Swizzling

WindowGroup {
    ContentView()
        .onOpenURL { url in
            _ = Evergage.sharedInstance().handleOpen(url)
        }
}

Keep SDK startup in your UIApplicationDelegate adapter. Handle any non-Personalization URLs in your app as appropriate.

For Objective-C, import Evergage.Swizzling to expose handleOpenURL:. In Swift, import Evergage and Evergage.Swizzling; the Objective-C selector handleOpenURL: is imported as handleOpen(_:).

These examples support single-scene campaign preview. Full multi-window campaign routing is not included in this update.

Forward Test URLs in a Legacy App

If your UIKit app doesn’t use scenes, define one of these open-URL methods in your UIApplicationDelegate:

  • application:openURL:options:
  • application:openURL:sourceApplication:annotation:
  • application:handleOpenURL:

By default, Personalization swizzles the open-URL method that you define and listens for test URLs. If you disable swizzling, call [Evergage(Swizzling) handleOpenURL:] from your open-URL method. For more information, see [Evergage(Swizzling) swizzlingEnabled].