Adobe Target helps test, personalize, and optimize mobile app experiences based on user behavior and mobile context. You can deliver interactions that engage and convert through iterative testing and rules-based and AI-powered personalization.
To get started with Target, follow these steps:
- Configure the Target extension in the Data Collection UI.
- Add the Target Extension to your app.
- Implement Target APIs to:
- Request mbox offers.
- Prefetch mbox offers.
- Track mboxes.
- Enter visual preview mode.
- In the Data Collection UI, click the Extensions tab.
- On the Catalog tab, locate the Adobe Target extension, and click Install.
- Your Target client code will be detected automatically.
- Optionally, provide your Environment ID.
- Set the timeout value to at least 5 seconds.
- Optionally, enter the Target workspace property token that was generated from Target UI.
- Click Save.
- Follow the publishing process to update SDK configuration.
To add the Target extension to your app:
{% tabs %} {% tab title="Android" %}
-
Add the Mobile Core and Target extensions to your project using the app's Gradle file.
implementation 'com.adobe.marketing.mobile:sdk-core:1.+' implementation 'com.adobe.marketing.mobile:target:1.+'
-
Import the Target extension to your application's main activity.
import com.adobe.marketing.mobile.*;
{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
-
Add the AEPCore, AEPIdentity, and AEPTarget CocoaPods to your project via your
Podfile
.pod 'AEPCore','~>3.0' pod 'AEPIdentity','~>3.0' pod 'AEPTarget','~>3.0'
-
Import the Target and Identity libraries.
Swift
import AEPCore
import AEPTarget
import AEPIdentity
Objective-C
@import AEPCore
@import AEPTarget
@import AEPIdentity
{% endtab %}
{% tab title="iOS (ACP 2.x)" %}
-
Add the ACPCore and ACPTarget CocoaPods to your project via your
Podfile
.pod 'ACPCore','~>2.0' pod 'ACPTarget','~>2.0'
-
Import the Target and Identity libraries.
Swift
import ACPCore
import ACPTarget
import ACPIdentity
Objective-C
#import "ACPCore.h"
#import "ACPTarget.h"
#import "ACPIdentity.h"
#import "ACPTargetRequestObject.h"
#import "ACPTargetPrefetchObject.h"
{% endtab %}
{% tab title="React Native" %}
-
Install Target.
npm install @adobe/react-native-acptarget react-native link @adobe/react-native-acptarget
-
Import the extension and related libraries.
import {ACPTarget, ACPTargetPrefetchObject, ACPTargetRequestObject, ACPTargetOrder, ACPTargetProduct, ACPTargetParameters} from '@adobe/react-native-acptarget';
-
Get the extension version.
ACPTarget.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPTarget version: " + version));
{% endtab %} {% endtabs %}
To register the Target extension with Mobile Core:
{% tabs %} {% tab title="Android" %}
In your Application's onCreate()
method, after calling the setApplication()
method, register Target with Mobile Core.
Here is code sample that calls these set up methods:
public class TargetApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
MobileCore.configureWithAppId("yourAppId");
try {
Target.registerExtension();
Identity.registerExtension();
MobileCore.start(null);
} catch (Exception e) {
//Log the exception
}
}
}
{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
MobileCore.registerExtensions([Target.self, Identity.self]) {
//Completion callback
// Use the App id assigned to this application via Adobe Data Collection UI
MobileCore.configureWith(appId: "yourAppId")
}
return true
}
In your app's didFinishLaunchingWithOptions
function, register the Target extension with Mobile Core:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[AEPMobileCore registerExtensions: @[AEPMobileIdentity.class, AEPMobileTarget.class] completion:^{
//Completion callback
// Use the app ID assigned to this application via Data Collection UI
[AEPMobileCore configureWithAppId: @"yourAppId"];
}];
return YES;
}
{% endtab %}
{% tab title="iOS (ACP 2.x)" %}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
ACPCore.configure(withAppId: "yourAppId")
ACPTarget.registerExtension()
ACPIdentity.registerExtension()
ACPCore.start(nil)
// Override point for customization after application launch.
return true
}
In your app's didFinishLaunchingWithOptions
function, register the Target extension with Mobile Core:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[ACPCore configureWithAppId:@"yourAppId"];
[ACPTarget registerExtension];
[ACPIdentity registerExtension];
[ACPCore start:nil];
// Override point for customization after application launch.
return YES;
}
{% endtab %}
{% tab title="React Native" %} To register the Target extension with the Mobile Core extension, use the following API:
ACPTarget.registerExtension();
{% endtab %} {% endtabs %}
Here is some information about the parameters in a Target request:
The TargetOrder
class encapsulates the order ID, the order total, and the purchased product IDs. You can instantiate this class to create order parameters. For more information about Target Order parameters, see Create an Order Confirmation mbox - mbox.js.
{% tabs %} {% tab title="Android" %}
public TargetOrder(final String id, final double total, final List<String> purchasedProductIds)
List<String> purchasedProductIds = new ArrayList<String>();
purchasedProductIds.add("34");
purchasedProductIds.add("125");
TargetOrder targetOrder = new TargetOrder("123", 567.89, purchasedProductIds);
{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
Syntax
public init(id: String, total: Double = 0, purchasedProductIds: [String]? = nil)
Examples
let order = TargetOrder(id: "id1", total: 1.0, purchasedProductIds: ["ppId1"])
Syntax
- (nonnull instancetype) initWithId: (nonnull NSString*) id total: (double) total purchasedProductIds: (nullable NSArray<NSString*>*) purchasedProductIds;
Examples
AEPTargetOrder *order = [[AEPTargetOrder alloc] initWithId:@"id1" total:1.0 purchasedProductIds:@[@"ppId1"]];
{% endtab %}
{% tab title="iOS (ACP 2.x)" %}
Syntax
public convenience init(id orderId: String, total: NSNumber?, purchasedProductIds: [String]?)
Examples
let order = ACPTargetOrder(id: "ADCKKBC", total: NSNumber(value: 400.50), purchasedProductIds: ["34", "125"])
Syntax
+ (nonnull instancetype) targetOrderWithId: (nonnull NSString*) orderId total: (nullable NSNumber*) total purchasedProductIds: (nullable NSArray <NSString*>*) purchasedProductIds;
Examples
ACPTargetOrder *order = [ACPTargetOrder targetOrderWithId:@"ADCKKBC" total:@(400.50) purchasedProductIds:@[@"34", @"125"]];
{% endtab %}
{% tab title="React Native" %} JavaScript
var targetOrder = new ACPTargetOrder("ADCKKBC", 400.50, ["34","125"]);
{% endtab %} {% endtabs %}
The TargetProduct
class encapsulates the product ID and the product category ID, and you can instantiate this class to create order parameters. For more information about Target Product parameters, see Entity attributes
{% tabs %} {% tab title="Android" %}
public TargetProduct(final String id, final String categoryId)
TargetProduct targetProduct = new TargetProduct("123", "Books");
{% endtab %}
{% tab title="iOS (ACP 3.x)" %}
Syntax
public init(productId: String, categoryId: String? = nil)
Examples
let product = TargetProduct(productId: "pId1", categoryId: "cId1")
Syntax
- (nonnull instancetype) initWithProductId:(nonnull NSString*) productId categoryId:(nullable NSString*) categoryId;
Examples
AEPTargetProduct *product =[[AEPTargetProduct alloc] initWithProductId:@"pId1" categoryId:@"cId1"];
{% endtab %}
{% tab title="iOS (ACP 2.x)" %}
Syntax
public convenience init(id productId: String, categoryId: String?)
Examples
let product = ACPTargetProduct(id: "24D334", categoryId: "Stationary")
Syntax
+ (nonnull instancetype) targetProductWithId: (nonnull NSString*) productId categoryId: (nullable NSString*) categoryId;
Examples
ACPTargetProduct *product = [ACPTargetProduct targetProductWithId:@"24D334" categoryId:@"Stationary"];
{% endtab %}
{% tab title="React Native" %} JavaScript
var targetProduct = new ACPTargetProduct("24D334", "Stationary");
{% endtab %} {% endtabs %}
TargetParameters
encapsulates mboxParameters
, profileParameters
, orderParameters
, and productParameters
and allows you easily pass these parameters in a Target request.
{% tabs %} {% tab title="Android" %}
TargetParameters targetParameters = new TargetParameters.Builder()
.parameters(new HashMap<String, String>())
.profileParameters(new HashMap<String, String>())
.product(new TargetProduct("productId", "productCategoryId"))
.order(new TargetOrder("orderId", 0.0, new ArrayList<String>()))
.build();
List<String> purchasedProductIds = new ArrayList<String>();
purchasedProductIds.add("34");
purchasedProductIds.add("125");
TargetOrder targetOrder = new TargetOrder("123", 567.89, purchasedProductIds);
TargetProduct targetProduct = new TargetProduct("123", "Books");
Map<String, String> mboxParameters = new HashMap<String, String>();
mboxParameters1.put("status", "platinum");
Map<String, String> profileParameters = new HashMap<String, String>();
profileParameters1.put("gender", "male");
TargetParameters targetParameters = new TargetParameters.Builder()
.parameters(mboxParameters)
.profileParameters(profileParameters)
.product(targetProduct)
.order(targetOrder)
.build();
{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
Syntax
public init(parameters: [String: String]? = nil, profileParameters: [String: String]? = nil, order: TargetOrder? = nil, product: TargetProduct? = nil)
Examples
let mboxParameters = [
"status": "Platinum"
]
let profileParameters = [
"gender": "female"
]
let order = TargetOrder(id: "id1", total: 1.0, purchasedProductIds: ["ppId1"])
let product = TargetProduct(productId: "pId1", categoryId: "cId1")
let targetParameters = TargetParameters(parameters: mboxParameters, profileParameters: profileParameters, order: order, product: product))
Syntax
- (nonnull instancetype) initWithParameters:(nullable NSDictionary<NSString*, NSString*>*) parameters profileParameters:(nullable NSDictionary<NSString*, NSString*>*) profileParameters order:(nullable AEPTargetOrder*) order product:(nullable AEPTargetProduct*) product;
Examples
NSDictionary *mboxParameters = @{@"status":@"Platinum"};
NSDictionary *profileParameters = @{@"gender":@"female"};
AEPTargetProduct *product =[[AEPTargetProduct alloc] initWithProductId:@"pId1" categoryId:@"cId1"];
AEPTargetOrder *order = [[AEPTargetOrder alloc] initWithId:@"id1" total:1.0 purchasedProductIds:@[@"ppId1"]];
AEPTargetParameters * targetParams = [[AEPTargetParameters alloc] initWithParameters:mboxParameters profileParameters:profileParameters order:order product:product];
{% endtab %}
{% tab title="iOS (ACP 2.x)" %}
Syntax
public convenience init(parameters: [AnyHashable: Any]?, profileParameters: [AnyHashable: Any]?, order: ACPTargetOrder?, product: ACPTargetProduct?)
Examples
let mboxParameters = [
"status": "Platinum"
]
let profileParameters = [
"gender": "female"
]
let product = ACPTargetProduct(id: "24D334", categoryId: "Stationary")
let order = ACPTargetOrder(id: "ADCKKBC", total: NSNumber(value: 400.50), purchasedProductIds: ["34", "125"])
let targetParameters = ACPTargetParameters(parameters: mboxParameters, profileParameters: profileParameters, product: product, order: order)
Syntax
+ (nonnull instancetype) targetParametersWithParameters: (nullable NSDictionary*) targetParameters profileParameters: (nullable NSDictionary*) profileParameters product: (nullable ACPTargetProduct*) product order: (nullable ACPTargetOrder*) order;
Examples
NSDictionary *mboxParameters = @{@"status":@"Platinum"};
NSDictionary *profileParameters = @{@"gender":@"female"};
ACPTargetProduct *product = [ACPTargetProduct targetProductWithId:@"24D334" categoryId:@"Stationary"];
ACPTargetOrder *order = [ACPTargetOrder targetOrderWithId:@"ADCKKBC" total:@(400.50) purchasedProductIds:@[@"34", @"125"]];
ACPTargetParameters *targetParameters = [ACPTargetParameters targetParametersWithParameters:mboxParameters
profileParameters:profileParameters
product:product
order:order];
{% endtab %}
{% tab title="React Native" %} JavaScript
var mboxParameters = {"status": "platinum"};
var profileParameters = {"gender": "female"};
var targetProduct = new ACPTargetProduct("24D334", "Stationary");
var purchaseIDs = ["34","125"];
var targetOrder = new ACPTargetOrder("ADCKKBC", 400.50, purchaseIDs);
var targetParameters = new ACPTargetParameters(mboxParameters, profileParameters, targetProduct, targetOrder);
{% endtab %} {% endtabs %}
TargetParameters
, such as mboxParameters
, profileParameters
, orderParameters
, and productParameters
, can be passed in the Target APIs and can also be passed in when you create TargetPrefetch
or TargetRequest
objects. The TargetParameters
that are passed in the public APIs are global parameters and are merged with the corresponding parameters in the individual TargetRequest
or TargetPrefetch
objects.
When merging, the new keys in the mbox parameters or the profile parameters are appended to the final dictionary, and the keys with the same name are overwritten in each TargetRequest
or TargetPrefetch
object by the keys from the global parameters. For TargetOrder
or TargetProduct
objects, the object that is passed to the global parameters replaces the corresponding object in the TargetRequest
or TargetPrefetch
objects.
The Target extension (version 2.1.4 for iOS) and (version 1.1.3 for Android) now supports persistent sessions. When a Target request is received, if a session ID does not exist, a new ID is generated and is sent in the request. This ID, with the Edge Host that is returned from Target, is kept in persistent storage for the configured target.sessionTimeout
period. If the timeout value is not configured, the default value is 30 minutes.
If no Target request is received during the configured target.sessionTimeout
or if the resetExperience API is called, these variables are reset and removed from persistent storage.
The visual preview mode allows you to easily perform end-to-end QA activities by enrolling and previewing these activities on your device. This mode does not require a specialized testing set up. To get started, set up a URL scheme and generate the preview links. For more information about setting up Target visual preview, see Target mobile preview. For more information about setting URL schemes for iOS, see Defining a Custom URL Scheme for Your App. For more information about setting URL schemes for Android, see Create Deep Links to App Content.
You can also set an application deep link that can be triggered when selections are made in the preview mode by using the setPreviewRestartDeeplink API.
To enter the preview visual mode, use the collectLaunchInfo
API to enable the mode and click the red floating button that appears on the app screen. For more information, see collectLaunchInfo.
{% hint style="info" %} After making preview mode selections, the first mbox request made may fail due to a caching issue on the Target server. For more information see the known issues and resolved issues document.
The mbox request that failed can be retried to successfully retrieve the test offer content. {% endhint %}
{% tabs %}
{% tab title="Android" %}
On Android, when the application is launched as a result of a deep link, the collectLaunchInfo
API is internally invoked, and the Target activity and deep link information is extracted from the Intent extras.
{% hint style="info" %}
The SDK can only collect information from the launching Activity if setApplication
has been called. Setting the Application is only necessary on an Activity that is also an entry point for your application. However, setting the Application on each Activity has no negative impact and ensures that the SDK always has the necessary reference to your Application. We recommend that you call setApplication
in each of your Activities.
{% endhint %}
{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
Syntax
public static func collectLaunchInfo(_ userInfo: [String: Any])
Examples
MobileCore.collectLaunchInfo(["adb_deeplink" : "com.adobe.targetpreview://app.adobetarget.com?at_preview_token=tokenFromTarget"])
Syntax
+ (void)collectLaunchInfo:(nonnull NSDictionary<NSString*, id>*) userInfo;
Examples
[AEPMobileCore collectLaunchInfo:@{@"adb_deeplink" : @"com.adobe.targetpreview://app.adobetarget.com?at_preview_token=tokenFromTarget"}];
{% endtab %}
{% tab title="iOS (ACP 2.x)" %}
Syntax
open class func collectLaunchInfo(_ userinfo: [AnyHashable: Any])
Examples
ACPCore.collectLaunchInfo(["adb_deeplink" : "com.adobe.targetpreview://app.adobetarget.com?at_preview_token=tokenFromTarget"])
Syntax
+ (void) collectLaunchInfo: (nonnull NSDictionary*) userInfo;
Examples
[ACPCore collectLaunchInfo: @{@"adb_deeplink":@"com.adobe.targetpreview://app.adobetarget.com?at_preview_token=tokenFromTarget"}];`
{% endtab %} {% endtabs %}
The SDK can minimize the number of times it reaches out to Target servers to fetch offers by caching server responses. With a successful prefetch call for mbox locations, offer content is retrieved and cached in the SDK. This content is retrieved from the cache for all future retrieveLocationContent API calls for the specified mbox names. This prefetch process reduces the offer load time and network calls that were made to the Target servers, and the prrocess allows Target to be notified which mbox was visited by the mobile app user.
{% hint style="warning" %} Prefetched offer content does not persist across application launches. The prefetch content is cached as long as the application lives in memory or until the API to clear the cache is called. For more information, see clearPrefetchCache. {% endhint %}
{% hint style="warning" %} Offer prefetch is not available while visual preview mode is enabled. {% endhint %}
To track the performance of your Target activities for certain segments, set up the Analytics for Target (A4T) cross-solution integration by enabling the A4T campaigns. This integration allows you to use Analytics reports to examine your results. If you use Analytics as the reporting source for an activity, all reporting and segmentation for that activity is based on Analytics data collection. For more information, see Adobe Analytics for Adobe Target (A4T).
Once Analytics is listed as the reporting source for an activity on Target UI, A4T works out of the box in the Target SDK. The Target SDK extension extracts the A4T payload from the Target server response, dispatches an event for Analytics SDK extension to send an internal track action request to the configured Analytics server.
The A4T payload returned from Target servers is sent to Adobe Analytics in the following cases:
- When one or more locations are retrieved using retrieveLocationContent API call.
- When one or more prefetched locations are loaded and a subsequent locationsDisplayed API call is made for the location(s).
{% hint style="warning" %} For A4T data to be sent to Adobe Analytics client-side, make sure Analytics SDK extension is installed and registered in your mobile application. For more information, see Adobe Analytics. {% endhint %}
To programmatically update SDK configuration, use the following information to change your Target configuration values:
For more information, see Programmatic updates to Configuration.
Key | Description | Data Type |
---|---|---|
target.clientcode | Client code for your account. | String |
target.timeout | Time, in seconds, to wait for a response from Target servers before timing out. | Integer |
target.environmentId | Environment ID you want to use. If the value is left blank, the default production environment will be used. | Integer |
target.propertyToken | at_property token value, which is generated from the Target UI. If this value is left blank, no token is sent in the Target network calls. |
String |
target.previewEnabled | Boolean parameter, which can be used to enable/disable Target Preview. If not specified, then Preview will be enabled by default. | Boolean |
target.sessionTimeout | The duration, in seconds, during which the Target session ID and Edge Host are persisted. If this value is not specified, the default timeout value is 30 minutes. | Integer |
target.server | Optional. If provided, all Target requests will be sent to this host. Available since v2.1.7 (iOS), v1.1.6 (Android). e.g. - mytargetdomain.com |
String |
{% hint style="warning" %} We recommend that, instead of passing the property token as a mbox parameter, you use an Experience Platform Launch configuration so that Target can pass the token. If the token is passed both in an Experience Platform Launch configuration, and as a mbox parameter, the token that was provided as the mbox parameter is discarded. {% endhint %}
{% hint style="warning" %}
Currently, the target.sessiontimeout
value can only be configured programmatically. For more information, see updateConfiguration.
{% endhint %}
- Want to get your Target client code? See the Client row in Configure mbox.js.
- What is an mbox? See How Target works in mobile apps.
- What is Analytics for Target (A4T)? See Adobe Analytics as the reporting source for Adobe Target (A4T).