Edit in GitHubLog an issue

Target API reference

clearPrefetchCache

This API clears the in-memory cache that contains the prefetched offers.

Java

Syntax

Copied to your clipboard
public static void clearPrefetchCache()

Example

Copied to your clipboard
Target.clearPrefetchCache();

extensionVersion

Returns the running version of the Target extension.

Java

Syntax

Copied to your clipboard
public String extensionVersion()

Example

Copied to your clipboard
Target.extensionVersion();

getSessionId

This API gets the Target session identifier.

The session ID is generated locally in the SDK upon initial Target request and persisted for a period defined by target.sessionTimeout configuration setting. If the session timeout happens upon a subsequent Target request, a new session ID will be generated for use in the request and persisted in the SDK.

Java

Syntax

Copied to your clipboard
public static void getSessionId(final AdobeCallback<String> callback)
  • callback is invoked with the sessionId value, or null if there was an error retrieving it.

Example

Copied to your clipboard
Target.getSessionId(new AdobeCallback<String>() {
@Override
public void call(String sessionId) {
// read Target sessionId
}
});

getThirdPartyId

This API gets the custom visitor ID for Target. If no third-party ID was previously set, or if the ID was reset by calling resetExperience API, it will have a nil value.

Java

Syntax

Copied to your clipboard
public static void getThirdPartyId(final AdobeCallback<String> callback)
  • callback is invoked with the thirdPartyId value. If no third-party ID was set, this value will be null.

Example

Copied to your clipboard
Target.getThirdPartyId(new AdobeCallback<String>() {
@Override
public void call(String thirdPartyId) {
// read Target thirdPartyId
}
});

getTntId

This API gets the Target user ID (also known as the tntId) from the Target service. The tntId is returned in the network response after a successful call to prefetchContent or retrieveLocationContent, which is then persisted in the SDK. This ID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall or when the resetExperience API is used.

Java

Syntax

Copied to your clipboard
public static void getTntId(final AdobeCallback<String> callback)
  • callback is invoked with the tntId value. If no Target ID was set, this value will be null.

Example

Copied to your clipboard
Target.getTntId(new AdobeCallback<String>() {
@Override
public void call(String tntId) {
// read target's tntid
}
});

locationClicked

This API sends a location click notification for an mbox to the configured Target server and can be invoked in the following cases:

  • For a prefetched mbox, after the mbox content is retrieved using the retrieveLocationContent API.
  • For a regular mbox, where no previous prefetch request is made, and the mbox content is retrieved using the retrieveLocationContent API.

Java

Syntax

Copied to your clipboard
public static void locationClicked(final String mboxName, final TargetParameters parameters)
  • mboxName is a String that contains the mbox location for which the click notification will be sent to Target.
  • parameters is the configured TargetParameters for the request.

Example

Copied to your clipboard
// Mbox parameters
Map<String, String> mboxParameters = new HashMap<>();
mboxParameters.put("membership", "prime");
// Product parameters
TargetProduct targetProduct = new TargetProduct("CEDFJC", "Electronics");
// Order parameters
List<String> purchasedIds = new ArrayList<String>();
purchasedIds.add("81");
purchasedIds.add("123");
purchasedIds.add("190");
TargetOrder targetOrder = new TargetOrder("NJJICK", "650", purchasedIds);
// Profile parameters
Map<String, String> profileParameters = new HashMap<>();
profileParameters.put("ageGroup", "20-32");
// Create Target Parameters
TargetParameters targetParameters = new TargetParameters.Builder(mboxParameters)
.profileParameters(profileParameters)
.order(targetOrder)
.product(targetProduct)
.build();
Target.locationClicked("cartLocation", targetParameters);

locationsDisplayed

This API sends a location display notification for an mbox to the configured Target server. The API should be invoked for a prefetched mbox after the mbox content is retrieved using the retrieveLocationContent API. If no previous prefetch request is made, and the mbox content is retrieved using the retrieveLocationContent API, calling this API does not trigger a notification request to the Target server.

Java

Syntax

Copied to your clipboard
public static void locationsDisplayed(final List<String> mboxNames, final TargetParameters targetParameters)
  • mboxNames is a list of the mbox locations for which the display notification will be sent to Target.
  • targetParameters is the configured TargetParameters for the request.

Example

Copied to your clipboard
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");
TargetParameters targetParameters = new TargetParameters.Builder()
.parameters(new HashMap<String, String>())
.profileParameters(new HashMap<String, String>())
.product(targetProduct)
.order(targetOrder)
.build();
List<String> mboxList = new ArrayList<>();
mboxList.add("mboxName1");
Target.locationsDisplayed(mboxList, targetParameters);

prefetchContent

This API sends a prefetch request to your configured Target server. The prefetch request is sent with the prefetch objects array and the specified Target parameters.

Java

Syntax

Copied to your clipboard
public static void prefetchContent(final List<TargetPrefetch> mboxPrefetchList, final TargetParameters parameters, final AdobeCallback<String> callback)
  • mboxPrefetchList is a list of TargetPrefetch objects for various mbox locations.
  • parameters is the configured TargetParameters for the prefetch request.
  • If the prefetch is successful, callback is invoked with a null value. If the prefetch is not successful, an error message is returned.

Example

Copied to your clipboard
// first prefetch request
Map<String, String> mboxParameters1 = new HashMap<>();
mboxParameters1.put("status", "platinum");
TargetParameters targetParameters1 = new TargetParameters.Builder()
.parameters(mboxParameters1)
.build();
TargetPrefetch prefetchRequest1 = new TargetPrefetch("mboxName1", targetParameters1);
// second prefetch request
Map<String, String> mboxParameters2 = new HashMap<>();
mboxParameters2.put("userType", "paid");
List<String> purchasedIds = new ArrayList<String>();
purchasedIds.add("34");
purchasedIds.add("125");
TargetOrder targetOrder = new TargetOrder("ADCKKIM", 344.30, purchasedIds);
TargetProduct targetProduct = new TargetProduct("24D3412", "Books");
TargetParameters targetParameters2 = new TargetParameters.Builder()
.parameters(mboxParameters2)
.product(targetProduct)
.order(targetOrder)
.build();
TargetPrefetch prefetchRequest2 = new TargetPrefetch("mboxName2", targetParameters2);
List<TargetPrefetch> prefetchMboxesList = new ArrayList<>();
prefetchMboxesList.add(prefetchRequest1);
prefetchMboxesList.add(prefetchRequest2);
// Call the prefetchContent API.
TargetParamters targetParameters = null;
Target.prefetchContent(prefetchMboxesList, targetParameters, prefetchStatusCallback);

registerExtension

Registers the Target extension with the Mobile Core.

Java

Syntax

Copied to your clipboard
public static void registerExtension()

Example

Copied to your clipboard
Target.registerExtension();

resetExperience

This API resets the user's experience by removing the visitor identifiers and resetting the Target session. Invoking this API also removes previously set Target user ID and custom visitor IDs, Target Edge Host, and the session information from persistent storage.

Java

Syntax

Copied to your clipboard
public static void resetExperience()

Example

Copied to your clipboard
Target.resetExperience();

retrieveLocationContent

This API sends a batch request to the configured Target server for multiple mbox locations.

A request will be sent to the configured Target server for mbox locations in the requests array for Target requests that have not been previously prefetched. The content for the mbox locations that have been prefetched in a previous request are returned from the SDK, and no additional network request is made. Each Target request object in the list contains a callback function, which is invoked when content is available for its given mbox location.

When using contentWithData callback to instantiate TargetRequest object, the following keys can be used to read response tokens and Analytics for Target (A4T) info from the data payload, if available in the Target response.

  • responseTokens (Response tokens)
  • analytics.payload (A4T payload)
  • clickmetric.analytics.payload (Click tracking A4T payload)

Java

Syntax

Copied to your clipboard
public static void retrieveLocationContent(final List<TargetRequest> targetRequestList, final TargetParameters parameters)
  • targetRequestList is a list of TargetRequest objects for various mbox locations.
  • parameters is the configured TargetParameters for the retrieve location request.

Example

Copied to your clipboard
// define parameters for first request
Map<String, String> mboxParameters1 = new HashMap<>();
mboxParameters1.put("status", "platinum");
TargetParameters parameters1 = new TargetParameters.Builder().parameters(mboxParameters1).build();
TargetRequest request1 = new TargetRequest("mboxName1", parameters1, "defaultContent1",
new AdobeCallback<String>() {
@Override
public void call(String value) {
// do something with target content.
}
});
// define parameters for second request
Map<String, String> mboxParameters2 = new HashMap<>();
mboxParameters2.put("userType", "paid");
List<String> purchasedIds = new ArrayList<String>();
purchasedIds.add("34");
purchasedIds.add("125");
TargetOrder targetOrder = new TargetOrder("ADCKKIM", 344.30, purchasedIds);
TargetProduct targetProduct = new TargetProduct("24D3412", "Books");
TargetParameters parameters2 = new TargetParameters.Builder()
.parameters(mboxParameters2)
.product(targetProduct)
.order(targetOrder)
.build();
TargetRequest request2 = new TargetRequest("mboxName2", parameters2, "defaultContent2",
new AdobeTargetDetailedCallback() {
@Override
public void call(final String content, final Map<String, Object> data) {
if (content != null && !content.isEmpty()) {
// do something with the target content.
}
// Read the data Map containing one or more of response tokens, analytics payload
// and click metric analytics payload, if available
if (data != null && !data.isEmpty()) {
Map<String, String> responseTokens = data.containsKey("responseTokens") ?
(Map<String, String>) data.get("responseTokens") :
null;
Map<String, String> analyticsPayload = data.containsKey("analytics.payload") ?
(Map<String, String>) data.get("analytics.payload") :
null;
Map<String, String> clickMetricAnalyticsPayload = data.containsKey("clickmetric.analytics.payload") ?
(Map<String, String>) data.get("clickmetric.analytics.payload") :
null;
...
}
}
@Overrides
void fail(final AdobeError error) {
// take appropriate action upon error.
}
});
// Creating Array of Request Objects
List<TargetRequest> locationRequests = new ArrayList<>();
locationRequests.add(request1);
locationRequests.add(request2);
// Define the profile parameters map.
Map<String, String> profileParameters1 = new HashMap<>();
profileParameters1.put("ageGroup", "20-32");
TargetParameters parameters = new TargetParameters.Builder().profileParameters(profileParameters1).build();
// Call the targetRetrieveLocationContent API.
Target.retrieveLocationContent(locationRequests, parameters);

This API sets a specific location in the app to be displayed when preview mode selections have been confirmed.

Java

Syntax

Copied to your clipboard
public static void setPreviewRestartDeepLink(final Uri deepLink)
  • deeplink is a URI that contains the preview restart deeplink.

Example

Copied to your clipboard
Target.setPreviewRestartDeepLink("myapp://HomePage");

setSessionId

This API sets the Target session identifier.

The provided session ID is persisted in the SDK for a period defined by target.sessionTimeout configuration setting. If the provided session ID is nil/null or empty, or if the privacy status is opted out, the SDK will remove the session ID value from the persistence.

This ID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall, upon privacy status update to opted out, or when the resetExperience API is used.

Java

Syntax

Copied to your clipboard
public static void setSessionId(final String sessionId)
  • sessionId is a String that contains the Target session identifier to be set in the SDK.

Example

Copied to your clipboard
Target.setSessionId("3f24b997-ea74-420c-81f8-96a8b92c3961");

setThirdPartyId

This API sets the custom visitor ID for Target. This ID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall or when the resetExperience API is used.

Java

Syntax

Copied to your clipboard
public static void setThirdPartyId(final String thirdPartyId)
  • thirdPartyId is a String that contains the custom visitor ID to be set in Target.

Example

Copied to your clipboard
Target.setThirdPartyId("third-party-id");

setTntId

This API sets the Target user identifier.

The provided tnt ID is persisted in the SDK and attached to subsequent Target requests. It is used to derive the edge host value in the SDK, which is also persisted and used in future Target requests. If the provided tnt ID is nil/null or empty, or if the privacy status is opted out, the SDK will remove the tnt ID and edge host values from the persistence.

This ID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall, upon privacy status update to opted out, or when the resetExperience API is used.

Java

Syntax

Copied to your clipboard
public static void setTntId(final String tntId)
  • tntId is a String that contains the Target user identifier to be set in the SDK.

Example

Copied to your clipboard
Target.setTntId("f741a5d5-09c0-4931-bf53-b9e568c5f782.35_0");

Visual preview

Target 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.

On Android, when the application is launched as a result of a deep link, the Mobile Core's collectLaunchInfo API is internally invoked, and the Target activity and deep link information is extracted from the Intent extras.

The SDK can only collect information from the launching Activity if setApplication API 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 API in each of your Activities.

Public classes

The following is a list of all the public classes available when using the Adobe Target extension.

Target request

TargetRequest

Java

Syntax

Copied to your clipboard
public class TargetRequest extends TargetObject {
/**
* Instantiate a TargetRequest object
* @param mboxName String mbox name for this request
* @param targetParameters TargetParameters for this request
* @param defaultContent String default content for this request
* @param contentCallback AdobeCallback<String> which will get called with Target mbox content
*/
public TargetRequest(final String mboxName,
final TargetParameters targetParameters,
final String defaultContent,
final AdobeCallback<String> contentCallback);
/**
* Instantiate a TargetRequest object.
*
* @param mboxName String mbox name for this request.
* @param targetParameters TargetParameters for this request.
* @param defaultContent String default content for this request.
* @param contentWithDataCallback AdobeTargetDetailedCallback which will get called with Target mbox content and other optional data such as Target response tokens, analytics payload, click metric analytics payload if available.
*/
public TargetRequest(final String mboxName,
final TargetParameters targetParameters,
final String defaultContent,
final AdobeTargetDetailedCallback contentWithDataCallback);
}

Target prefetch

TargetPrefetch

Java

Syntax

Copied to your clipboard
public class TargetPrefetch extends TargetObject {
/**
* Instantiate a TargetPrefetch object
* @param mboxName String mbox name for this prefetch request
* @param targetParameters TargetParameters for this prefetch request
*/
public TargetPrefetch(final String mboxName, final TargetParameters targetParameters)
}

Target parameters

TargetParameters

Java

Syntax

Copied to your clipboard
public class TargetParameters {
private TargetParameters() {}
/**
* Builder used to construct a TargetParameters object
*/
public static class Builder {
private Map<String, String> parameters;
private Map<String, String> profileParameters;
private TargetProduct product;
private TargetOrder order;
/**
* Create a TargetParameters object Builder
*/
public Builder() {}
/**
* Create a TargetParameters object Builder
*
* @param parameters mbox parameters for the built TargetParameters
*/
public Builder(final Map<String, String> parameters);
/**
* Set mbox parameters on the built TargetParameters
*
* @param parameters mbox parameters map
* @return this builder
*/
public Builder parameters(final Map<String, String> parameters);
/**
* Set profile parameters on the built TargetParameters
*
* @param profileParameters profile parameters map
* @return this builder
*/
public Builder profileParameters(final Map<String, String> profileParameters);
/**
* Set product parameters on the built TargetParameters
*
* @param product product parameters
* @return this builder
*/
public Builder product(final TargetProduct product);
/**
* Set order parameters on the built TargetParameters
*
* @param order order parameters
* @return this builder
*/
public Builder order(final TargetOrder order);
/**
* Build the TargetParameters object
*
* @return the built TargetParameters object
*/
public TargetParameters build();
}
}

Target order

TargetOrder

This class contains an orderId, an order total, and an array for purchasedProductIds.

Java

Syntax

Copied to your clipboard
public class TargetOrder {
/**
* Initialize a TargetOrder with an order id, order total and a list of purchasedProductIds
*
* @param id String order id
* @param total double order total amount
* @param purchasedProductIds a list of purchased product ids
*/
public TargetOrder(final String id, final double total, final List<String> purchasedProductIds);
/**
* Get the order id
*
* @return order id
*/
public String getId();
/**
* Get the order total
*
* @return order total
*/
public double getTotal();
/**
* Get the order purchasedProductIds
*
* @return a list of this order's purchased product ids
*/
public List<String> getPurchasedProductIds();
}

Target product

TargetProduct

Java

Syntax

Copied to your clipboard
public class TargetProduct {
/**
* Initialize a TargetProduct with a product id and a productCategoryId categoryId
*
* @param id String product id
* @param categoryId String product category id
*/
public TargetProduct(final String id, final String categoryId);
/**
* Get the product id
*
* @return product id
*/
public String getId();
/**
* Get the product categoryId
*
* @return product category id
*/
public String getCategoryId();
}
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.