Edit in GitHubLog an issue

Java

Syntax

Copied to your clipboard
static void trackAsset(String assetURL)
static void trackAsset(String assetURL, InteractionType interactionType)
static void trackAsset(String assetURL, InteractionType interactionType, String assetLocation)
static void trackAsset(String assetURL, InteractionType interactionType, String assetLocation, Map<String, Object> additionalData)

Example

Copied to your clipboard
// Using InteractionType enum directly
ContentAnalytics.trackAsset(
"https://example.com/image.jpg",
InteractionType.VIEW,
"home"
);

Kotlin

Syntax

Copied to your clipboard
fun trackAsset(
assetURL: String,
interactionType: InteractionType = InteractionType.VIEW,
assetLocation: String? = null,
additionalData: Map<String, Any>? = null
): Unit

Example

Copied to your clipboard
// Using InteractionType enum directly
ContentAnalytics.trackAsset(
assetURL: "https://example.com/image.jpg",
interactionType: InteractionType.VIEW,
assetLocation: "home"
);

Swift

Syntax

Copied to your clipboard
static func trackAsset(
assetURL: String,
interactionType: InteractionType = .view,
assetLocation: String? = nil,
additionalData: [String: Any]? = nil
)

Example

Copied to your clipboard
ContentAnalytics.trackAsset(
assetURL: "https://example.com/image.jpg",
interactionType: InteractionType.VIEW,
assetLocation: "home"
);

Objective-C

Syntax

Copied to your clipboard
+ (void)trackAsset:(NSString *)assetURL
interactionType:(AEPInteractionType)interactionType
assetLocation:(nullable NSString *)assetLocation
additionalData:(nullable NSDictionary<NSString *,id> *)additionalData;

Example

Copied to your clipboard
[AEPContentAnalytics trackAsset:@"https://example.com/image.jpg"
interactionType:AEPInteractionTypeView
assetLocation:@"home"];

Java

Syntax

Copied to your clipboard
static void trackAssetView(String assetURL)
static void trackAssetView(String assetURL, String assetLocation)
static void trackAssetView(String assetURL, String assetLocation, Map<String, Object> additionalData)additionalData)

Example

Copied to your clipboard
// Using InteractionType enum directly
ContentAnalytics.trackAssetView(
"https://example.com/image.jpg",
"home"
);

Kotlin

Syntax

Copied to your clipboard
fun trackAssetView(
assetURL: String,
assetLocation: String? = null,
additionalData: Map<String, Any>? = null
): Unit

Example

Copied to your clipboard
// Using InteractionType enum directly
ContentAnalytics.trackAssetView(
assetURL: "https://example.com/image.jpg",
assetLocation: "home"
);

Swift

Syntax

Copied to your clipboard
static func trackAssetView(
assetURL: String,
assetLocation: String? = nil,
additionalData: [String: Any]? = nil
)

Example

Copied to your clipboard
ContentAnalytics.trackAsset(
assetURL: "https://example.com/image.jpg",
assetLocation: "home"
);

Objective-C

Syntax

Copied to your clipboard
+ (void)trackAssetView:(NSString *)assetURL
assetLocation:(nullable NSString *)assetLocation
additionalData:(nullable NSDictionary<NSString *,id> *)additionalData;

Example

Copied to your clipboard
[AEPContentAnalytics trackAssetView:@"https://example.com/image.jpg"
assetLocation:@"home"];

Java

Syntax

Copied to your clipboard
static void trackAssetClick(String assetURL)
static void trackAssetClick(String assetURL, String assetLocation)
static void trackAssetClick(String assetURL, String assetLocation, Map<String, Object> additionalData)

Example

Copied to your clipboard
// Using InteractionType enum directly
ContentAnalytics.trackAssetClick(
"https://example.com/image.jpg",
"home",
null
);

Kotlin

Syntax

Copied to your clipboard
fun trackAssetClick(
assetURL: String,
assetLocation: String? = null,
additionalData: Map<String, Any>? = null
): Unit

Example

Copied to your clipboard
// Using InteractionType enum directly
ContentAnalytics.trackAssetClick(
"https://example.com/image.jpg",
"home",
null
);

Swift

Syntax

Copied to your clipboard
static func trackAssetClick(
assetURL: String,
assetLocation: String? = nil,
additionalData: [String: Any]? = nil
)

Example

Copied to your clipboard
ContentAnalytics.trackAssetClick(
assetURL: "https://example.com/image.jpg",
assetLocation: "home"
);

Objective-C

Syntax

Copied to your clipboard
+ (void)trackAssetClick:(NSString *)assetURL
assetLocation:(nullable NSString *)assetLocation
additionalData:(nullable NSDictionary<NSString *,id> *)additionalData;

Example

Copied to your clipboard
[AEPContentAnalytics trackAssetClick:@"https://example.com/image.jpg"
assetLocation:@"home"];

Java

Syntax

Copied to your clipboard
static void trackAssetCollection(List<String> assetURLs)
static void trackAssetCollection(List<String> assetURLs, InteractionType interactionType)
static void trackAssetCollection(List<String> assetURLs, InteractionType interactionType, String assetLocation)

Example

Copied to your clipboard
ContentAnalytics.trackAssetCollection(
List.of(
"https://example.com/img1.jpg",
"https://example.com/img2.jpg"
),
"product-carousel"
);

Kotlin

Syntax

Copied to your clipboard
fun trackAssetCollection(
assetURLs: List<String>,
interactionType: InteractionType = InteractionType.VIEW,
assetLocation: String? = null
): Unit

Example

Copied to your clipboard
ContentAnalytics.trackAssetCollection(
assetURLs = listOf(
"https://example.com/img1.jpg",
"https://example.com/img2.jpg"
),
assetLocation = "product-carousel"
);

Swift

Syntax

Copied to your clipboard
static func trackAssetCollection(
assetURLs: [String],
interactionType: InteractionType = .view,
assetLocation: String? = nil
)

Example

Copied to your clipboard
ContentAnalytics.trackAssetCollection(
assetURLs: ["https://example.com/image1.jpg", "https://example.com/image1.jpg"],
assetLocation: "home"
);

Objective-C

Syntax

Copied to your clipboard
+ (void)trackAssetCollectionWithAssetURLs:(NSArray<NSString *> *)assetURLs
interactionType:(AEPInteractionType)interactionType
assetLocation:(nullable NSString *)assetLocation;

Example

Copied to your clipboard
[AEPContentAnalytics trackAssetCollectionWithAssetURLs:@[@"https://example.com/image1.jpg",@"https://example.com/image1.jpg"]
interactionType:AEPInteractionTypeView
assetLocation:@"home"];

Java

Syntax

Copied to your clipboard
static String registerExperience(List<ContentItem> assets, List<ContentItem> texts)
static String registerExperience(List<ContentItem> assets, List<ContentItem> texts, List<ContentItem> ctas)

Example

Copied to your clipboard
String expId = ContentAnalytics.registerExperience(
List.of(
new ContentItem("https://example.com/product.jpg")
),
List.of(
new ContentItem("iPhone 16 Pro", Map.of("role", "headline")),
new ContentItem("$999", Map.of("role", "price"))
),
List.of(
new ContentItem("Buy Now", Map.of("enabled", true))
)
);
ContentAnalytics.trackExperienceView(expId, "product.detail")

Kotlin

Syntax

Copied to your clipboard
fun registerExperience(
assets: List<ContentItem>,
texts: List<ContentItem>,
ctas: List<ContentItem>? = null
): String

Example

Copied to your clipboard
// Using InteractionType enum directly
val expId = ContentAnalytics.registerExperience(
assets = listOf(
ContentItem("https://example.com/product.jpg")
),
texts = listOf(
ContentItem("iPhone 16 Pro", mapOf("role" to "headline")),
ContentItem("$999", mapOf("role" to "price"))
),
ctas = listOf(
ContentItem("Buy Now", mapOf("enabled" to true))
)
);
ContentAnalytics.trackExperienceView(experienceId: expId, experienceLocation: "product.detail")

Swift

Syntax

Copied to your clipboard
@discardableResult
static func registerExperience(
assets: [ContentItem],
texts: [ContentItem],
ctas: [ContentItem]? = nil
) -> String

Example

Copied to your clipboard
let expId = ContentAnalytics.registerExperience(
assets: [ContentItem(value: "https://example.com/product.jpg", styles: [:])],
texts: [
ContentItem(value: "iPhone 16 Pro", styles: ["role": "headline"]),
ContentItem(value: "$999", styles: ["role": "price"])
],
ctas: [ContentItem(value: "Buy Now", styles: ["enabled": true])]
)
ContentAnalytics.trackExperienceView(experienceId: expId, experienceLocation: "product.detail")

Objective-C

Syntax

Copied to your clipboard
+ (NSString *)registerExperienceWithAssets:(NSArray<AEPContentItem *> *)assets
texts:(NSArray<AEPContentItem *> *)texts
ctas:(nullable NSArray<AEPContentItem *> *)ctas;

Example

Copied to your clipboard
NSString *expId = [AEPContentAnalytics registerExperienceWithAssets:@[
[[AEPContentItem alloc] initWithValue:@"https://example.com/product.jpg" styles:@{}]
]
texts:@[
[[AEPContentItem alloc] initWithValue:@"iPhone 16 Pro" styles:@{@"role": @"headline"}],
[[AEPContentItem alloc] initWithValue:@"$999" styles:@{@"role": @"price"}]
]
ctas:@[
[[AEPContentItem alloc] initWithValue:@"Buy Now" styles:@{@"enabled": @YES}]
]];
[AEPContentAnalytics trackExperienceViewWithExperienceId:expId
experienceLocation:@"product.detail"];

Java

Syntax

Copied to your clipboard
static void trackExperienceView(String experienceId)
static void trackExperienceView(String experienceId, String experienceLocation)
static void trackExperienceView(String experienceId, String experienceLocation, Map<String, Object> additionalData)

Example

Copied to your clipboard
ContentAnalytics.trackExperienceView(
expId,
"homepage.hero",
Map.of("viewDuration", 5.2)
);

Kotlin

Syntax

Copied to your clipboard
fun trackExperienceView(
experienceId: String,
experienceLocation: String? = null,
additionalData: Map<String, Any>? = null
): Unit

Example

Copied to your clipboard
// Using InteractionType enum directly
ContentAnalytics.trackExperienceView(
experienceId: expId,
experienceLocation: "homepage.hero",
additionalData: ["viewDuration": 5.2]
)

Swift

Syntax

Copied to your clipboard
static func trackExperienceView(
experienceId: String,
experienceLocation: String? = nil,
additionalData: [String: Any]? = nil
)

Example

Copied to your clipboard
ContentAnalytics.trackExperienceView(
experienceId: expId,
experienceLocation: "homepage.hero",
additionalData: ["viewDuration": 5.2]
)

Objective-C

Syntax

Copied to your clipboard
+ (void)trackExperienceView:(NSString *)assetURL
assetLocation:(nullable NSString *)assetLocation
additionalData:(nullable NSDictionary<NSString *,id> *)additionalData;

Example

Copied to your clipboard
[AEPContentAnalytics trackExperienceView:expId
experienceLocation:@"homepage.hero"
additionalData:@{@"viewDuration": @5.2}];

Java

Syntax

Copied to your clipboard
static void trackExperienceClick(String experienceId)
static void trackExperienceClick(String experienceId, String experienceLocation)
static void trackExperienceClick(String experienceId, String experienceLocation, Map<String, Object> additionalData)

Example

Copied to your clipboard
ContentAnalytics.trackExperienceClick(
expId,
"homepage.hero",
Map.of("viewDuration", 5.2)
);

Kotlin

Syntax

Copied to your clipboard
fun trackExperienceClick(
experienceId: String,
experienceLocation: String? = null,
additionalData: Map<String, Any>? = null
): Unit

Example

Copied to your clipboard
// Using InteractionType enum directly
ContentAnalytics.trackExperienceClick(
experienceId: expId,
experienceLocation: "homepage.hero",
additionalData: ["viewDuration": 5.2]
)

Swift

Syntax

Copied to your clipboard
static func trackExperienceClick(
experienceId: String,
experienceLocation: String? = nil,
additionalData: [String: Any]? = nil
)

Example

Copied to your clipboard
ContentAnalytics.trackExperienceClick(
experienceId: expId,
experienceLocation: "homepage.hero",
additionalData: ["viewDuration": 5.2]
)

Objective-C

Syntax

Copied to your clipboard
+ (void)trackExperienceClick:(NSString *)assetURL
assetLocation:(nullable NSString *)assetLocation
additionalData:(nullable NSDictionary<NSString *,id> *)additionalData;

Example

Copied to your clipboard
[AEPContentAnalytics trackExperienceClick:expId
experienceLocation:@"homepage.hero"
additionalData:@{@"viewDuration": @5.2}];

Java

Syntax

Copied to your clipboard
public class ContentItem {
private final String value;
private final Map<String, Object> styles;
public ContentItem(String value, Map<String, Object> styles) {
this.value = value;
this.styles = styles;
}
// Convenience constructor to mirror the default parameter
public ContentItem(String value) {
this(value, Collections.emptyMap());
}
public String getValue() {
return value;
}
public Map<String, Object> getStyles() {
return styles;
}
public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<>();
map.put("value", value);
map.put("styles", styles);
return map;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ContentItem)) return false;
ContentItem that = (ContentItem) o;
return Objects.equals(value, that.value) &&
Objects.equals(styles, that.styles);
}
@Override
public int hashCode() {
return Objects.hash(value, styles);
}
@Override
public String toString() {
return "ContentItem{value='" + value + "', styles=" + styles + "}";
}
}

Example

Copied to your clipboard
// Asset with URL
ContentItem("https://example.com/hero.jpg")
// Text with role
ContentItem("Welcome!", mapOf("role" to "headline"))
// CTA with enabled state
ContentItem("Shop Now", mapOf("enabled" to true, "role" to "primary"))

Kotlin

Syntax

Copied to your clipboard
data class ContentItem(
val value: String,
val styles: Map<String, Any> = emptyMap()
) {
fun toMap(): Map<String, Any>
}

Example

Copied to your clipboard
// Asset with URL
ContentItem(value: "https://example.com/hero.jpg")
// Text with role
ContentItem(value: "Welcome!", styles: mapOf("role" to "headline"))
// CTA with enabled state
ContentItem(value: "Shop Now", styles: mapOf("enabled" to true, "role" to "primary"))

Swift

Syntax

Copied to your clipboard
public struct ContentItem {
let value: String
let styles: [String: Any]
init(value: String, styles: [String: Any])
}

Example

Copied to your clipboard
// Asset
ContentItem(value: "https://example.com/image.jpg", styles: [:])
// Text with role
ContentItem(value: "Product Title", styles: ["role": "headline"])
ContentItem(value: "$99.99", styles: ["role": "price"])
// CTA
ContentItem(value: "Buy Now", styles: ["enabled": true])

Objective-C

Syntax

Copied to your clipboard
@implementation AEPContentItem
- (instancetype)initWithValue:(NSString *)value
styles:(NSDictionary<NSString *, id> *)styles {
if (self = [super init]) {
_value = value;
_styles = styles;
}
return self;
}

Example

Copied to your clipboard
AEPContentItem *asset = [[AEPContentItem alloc] initWithValue:@"https://example.com/image.jpg"
styles:@{}];
AEPContentItem *title = [[AEPContentItem alloc] initWithValue:@"Product Title"
styles:@{@"role": @"headline"}];
AEPContentItem *price = [[AEPContentItem alloc] initWithValue:@"$99.99"
styles:@{@"role": @"price"}];
AEPContentItem *cta = [[AEPContentItem alloc] initWithValue:@"Buy Now"
styles:@{@"enabled": @YES}];

Java

Syntax

Copied to your clipboard
public enum InteractionType {
VIEW,
CLICK,
DEFINITION;
public String getStringValue() {
return name().toLowerCase();
}
}

Example

Copied to your clipboard
ContentAnalytics.trackAsset(
"https://example.com/hero.jpg",
InteractionType.VIEW
)

Kotlin

Syntax

Copied to your clipboard
enum class InteractionType {
VIEW,
CLICK,
DEFINITION;
val stringValue: String
get() = name.lowercase()
}

Example

Copied to your clipboard
ContentAnalytics.trackAsset(
assetURL = "https://example.com/hero.jpg",
interactionType = InteractionType.VIEW
)

Swift

Syntax

Copied to your clipboard
public enum InteractionType: Int {
case view = 0
case click = 1
public var stringValue: String { ... }
public static func from(string: String) -> InteractionType?
}

Example

Copied to your clipboard
ContentAnalytics.trackAsset(
assetURL: "https://example.com/hero.jpg",
interactionType: .view
)

Objective-C

Syntax

Copied to your clipboard
@objc(AEPInteractionType)
public enum InteractionType: Int {
case view = 0
case click = 1
public var stringValue: String { ... }
public static func from(string: String) -> InteractionType?
}

Example

Copied to your clipboard
[ContentAnalytics trackAsset:@"https://example.com/hero.jpg"
interactionType:AEPInteractionTypeView
assetLocation:nil
additionalData:nil];
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2026 Adobe. All rights reserved.