Edit in GitHubLog an issue

iOS - create a Target location and success metric

To use Target in your mobile app, create a location and success metric.

This section includes sample code that can be used as a template for your app. The samples in this section contain code for iOS. The same patterns apply to Android. Android-specific syntax can be found in the Android SDK 4.x for Experience Cloud Solutions guide.

To create a Target location in your app and make a request, there are two primary methods:

  • targetCreateRequestWithName
  • targetLoadRequest
  1. Create a Target location.

    Here is a sample call to create a request:

    Copied to your clipboard
    1// make your request
    2ADBTargetLocationRequest *myRequest = [ADBMobile targetCreateRequestWithName:@"heroBanner"
    3 defaultContent:@"default.png"
    4 parameters:nil];
    ParameterDescription
    ADBTargetLocationRequest *myRequestReplace myRequest with the name of your targetLocation in the app.
    targetCreateRequestWithName:@"heroBanner"Replace heroBanner with the name of your targetLocation in Target. This is the same as the mbox name. This hero banner appears in the Target interface.
    defaultContent:@"default.png"Replace default.png with the value the app uses if Target doesn't respond.
    parameters:nilSpecify profile or mbox parameters. See more information in the 'Passing custom data' section.

    Here is a sample call to load the request:

    Copied to your clipboard
    1// load your request
    2[ADBMobile targetLoadRequest:myRequest callback:^(NSString *content) {
    3 // do something with content
    4 heroImage.image = [UIImage imageNamed:content];
    5}];
    ParameterDescription
    targetLoadRequest:myRequestReplace myRequest with the name of your targetLocation in the app.
    NSString *contentReplace content with the actual content coming back from Adobe. The string can be XML, JSON or a plain string. Use this section of the code to define variables, set image paths, view controller flows, transaction points, or anything else you want to do. Target will return the content entered in the UI in the exact same format.
    heroImage.image = [UIImage imageNamed:content];For example: Take content and set the path for a hero image.
  2. Create a success metric.

    The method targetCreateOrderConfirmRequestWithName can be used to track a conversion/success metric in your app.

    Copied to your clipboard
    1ADBTargetLocationRequest *req = [ADBMobile targetCreateOrderConfirmRequestWithName: "orderConfirm"
    2 orderId: orderId
    3 orderTotal: @"39.95"
    4 productPurchasedId: _galleryItem.title
    5 parameters: nil];
    6[ADBMobile targetLoadRequest: req callback: nil];
    ParameterDescription
    orderIdReplace with a dynamic variable representing a unique order ID.
    @"39.95"Replace with a dynamic variable representing a unique order total.
    _galleryItem.titleReplace with a dynamic variable representing a comma-delimited list of products purchased.
    parameters: nilOptional dictionary of additional parameters.
  3. Build the app.

    Step Result After you have successfully created a target location and tagged a success metric, create an A/B test. The activity can be created using the form-based experience composer.

Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.