Analytics API reference
clearQueue
Force delete, without sending to Analytics, all hits being stored or batched on the SDK.
Use caution when manually clearing the queue. This operation cannot be reverted.
extensionVersion
The extensionVersion()
API returns the version of the Analytics extension that is registered with the Mobile Core extension.
To get the version of the Analytics extension, use the following code sample:
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet version = Analytics.extensionVersion
Objective-C
Syntax
Copied to your clipboard+ (nonnull NSString*) extensionVersion;
Example
Copied to your clipboardNSString *version = [AEPMobileAnalytics extensionVersion];
Java
Syntax
Copied to your clipboardpublic static String extensionVersion()
Example
Copied to your clipboardString analyticsExtensionVersion = Analytics.extensionVersion();
Kotlin
Example
Copied to your clipboardval extensionVersion = Analytics.extensionVersion();
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet version = Analytics.extensionVersion
Objective-C
Syntax
Copied to your clipboard+ (nonnull NSString*) extensionVersion;
Example
Copied to your clipboardNSString *version = [AEPMobileAnalytics extensionVersion];
getQueueSize
Retrieves the total number of Analytics hits in the tracking queue.
Java
Syntax
Copied to your clipboardpublic static void getQueueSize(@NonNull final AdobeCallback<Long> callback)
Example
Copied to your clipboardAnalytics.getQueueSize(new AdobeCallbackWithError<Long>() {@Overridepublic void fail(AdobeError adobeError) {// Handle the error}@Overridepublic void call(Long size) {// Handle the queue size}});
Kotlin
Example
Copied to your clipboardAnalytics.getQueueSize(object: AdobeCallbackWithError<Long> {override fun call(size: Long?) {// Handle the queue size}override fun fail(error: AdobeError?) {// Handle the error}})
Please use the getQueueSizeWithCompletionHandler API instead.
Java
Syntax
Copied to your clipboardpublic static void getQueueSize(@NonNull final AdobeCallback<Long> callback)
Example
Copied to your clipboardAnalytics.getQueueSize(new AdobeCallbackWithError<Long>() {@Overridepublic void fail(AdobeError adobeError) {// Handle the error}@Overridepublic void call(Long size) {// Handle the queue size}});
Kotlin
Example
Copied to your clipboardAnalytics.getQueueSize(object: AdobeCallbackWithError<Long> {override fun call(size: Long?) {// Handle the queue size}override fun fail(error: AdobeError?) {// Handle the error}})
Please use the getQueueSizeWithCompletionHandler API instead.
getQueueSizeWithCompletionHandler
Retrieves the total number of Analytics hits in the tracking queue. Invoke the callback with NSError if an unexpected error occurs or the request times out.
iOS
Swift
Syntax
Copied to your clipboardstatic func getQueueSize(completion: @escaping (Int, Error?) -> Void)
Example
Copied to your clipboardAnalytics.getQueueSize { (queueSize, error) in// Handle error (if non-nil) or use queueSize.}
Objective-C
Syntax
Copied to your clipboard+ (void)getQueueSize:^(NSInteger, NSError * _Nullable)completion
Example
Copied to your clipboard[AEPMobileAnalytics getQueueSize:^(NSInteger queueSize, NSError * _Nullable error) {// Handle error (if non-nil) or use queueSize.}];
Swift
Syntax
Copied to your clipboardstatic func getQueueSize(completion: @escaping (Int, Error?) -> Void)
Example
Copied to your clipboardAnalytics.getQueueSize { (queueSize, error) in// Handle error (if non-nil) or use queueSize.}
Objective-C
Syntax
Copied to your clipboard+ (void)getQueueSize:^(NSInteger, NSError * _Nullable)completion
Example
Copied to your clipboard[AEPMobileAnalytics getQueueSize:^(NSInteger queueSize, NSError * _Nullable error) {// Handle error (if non-nil) or use queueSize.}];
getTrackingIdentifier
Retrieves the Analytics tracking identifier that is generated for this app/device instance. This identifier is an app-specific, unique visitor ID that is generated at the initial launch and is stored and used after the initial launch. The ID is preserved between app upgrades and is removed when the app is uninstalled as well as on MobileCore.resetIdentities API call or on privacy status opt out.
Starting with v1.2.9 (Android) / v3.0.3(iOS AEPAnalytics) / v2.5.1 (iOS ACPAnalytics) this API does not generate or retrieve a new tracking identifier (AID) for new visitors. For the visitors which have an AID previously generated will continue retrieve the AID value with this API, and new users will use the ECID (MID) value as the primary identity.
Before using this API, see the documentation on identifying unique visitors.
Java
Syntax
Copied to your clipboardpublic static void getTrackingIdentifier(@NonNull final AdobeCallback<String> callback)
- callback is invoked with the tracking Identifier string value. When an AdobeCallbackWithError is provided, an AdobeError can be returned in the eventuality of an unexpected error or if the default timeout (5000ms) is met before the callback is returned with analytics tracking identifier.
Example
Copied to your clipboardAnalytics.getTrackingIdentifier(new AdobeCallbackWithError<String>() {@Overridepublic void fail(AdobeError adobeError) {// Handle the error}@Overridepublic void call(String s) {// Handle the Experience Cloud ID}});
Kotlin
Example
Copied to your clipboardAnalytics.getTrackingIdentifier(object: AdobeCallbackWithError<String> {override fun call(id: String?) {// Handle the Experience Cloud ID}override fun fail(error: AdobeError?) {// Handle the error}})
Please see the getTrackingIdentifierWithCompletionHandler section for using this API call.
Java
Syntax
Copied to your clipboardpublic static void getTrackingIdentifier(@NonNull final AdobeCallback<String> callback)
- callback is invoked with the tracking Identifier string value. When an AdobeCallbackWithError is provided, an AdobeError can be returned in the eventuality of an unexpected error or if the default timeout (5000ms) is met before the callback is returned with analytics tracking identifier.
Example
Copied to your clipboardAnalytics.getTrackingIdentifier(new AdobeCallbackWithError<String>() {@Overridepublic void fail(AdobeError adobeError) {// Handle the error}@Overridepublic void call(String s) {// Handle the Experience Cloud ID}});
Kotlin
Example
Copied to your clipboardAnalytics.getTrackingIdentifier(object: AdobeCallbackWithError<String> {override fun call(id: String?) {// Handle the Experience Cloud ID}override fun fail(error: AdobeError?) {// Handle the error}})
Please see the getTrackingIdentifierWithCompletionHandler section for using this API call.
getTrackingIdentifierWithCompletionHandler
Starting with v1.2.9 (Android) / v3.0.3(iOS AEPAnalytics) / v2.5.1 (iOS ACPAnalytics) this API does not generate or retrieve a new tracking identifier (AID) for new visitors. For the visitors which have an AID previously generated will continue retrieve the AID value with this API, and new users will use the ECID (MID) value as the primary identity.
Before you use this API, please read the documentation on identifying unique visitors.
Retrieves the Analytics tracking identifier that is generated for this app/device instance. This identifier is an app-specific, unique visitor ID that is generated at the initial launch and is stored and used after the initial launch. The ID is preserved between app upgrades and is removed when the app is uninstalled. Invoke the callback with NSError if an unexpected error occurs or the request times out.
If you have an Experience Cloud ID and have not yet configured a visitor ID grace period, the value returned by getTrackingIdentifier
may be null.
iOS
Swift
Syntax
Copied to your clipboardstatic func getTrackingIdentifier(completion: @escaping (String?, Error?) -> Void)
Example
Copied to your clipboardAnalytics.getTrackingIdentifier { (trackingId, error) in// Handle the error (if non-nil) or use the trackingIdentifier value}
Objective-C
Syntax
Copied to your clipboard+ (void) getTrackingIdentifier:^(NSString * _Nullable, NSError * _Nullable)completion
Example
Copied to your clipboardAEPMobileAnalytics getTrackingIdentifier:^(NSString * _Nullable trackingIdentifier, NSError * _Nullable error) {// Handle the error (if non-nil) or use the trackingIdentifier value}];
Swift
Syntax
Copied to your clipboardstatic func getTrackingIdentifier(completion: @escaping (String?, Error?) -> Void)
Example
Copied to your clipboardAnalytics.getTrackingIdentifier { (trackingId, error) in// Handle the error (if non-nil) or use the trackingIdentifier value}
Objective-C
Syntax
Copied to your clipboard+ (void) getTrackingIdentifier:^(NSString * _Nullable, NSError * _Nullable)completion
Example
Copied to your clipboardAEPMobileAnalytics getTrackingIdentifier:^(NSString * _Nullable trackingIdentifier, NSError * _Nullable error) {// Handle the error (if non-nil) or use the trackingIdentifier value}];
getVisitorIdentifier
Before using this API, please read the documentation on identifying unique visitors.
This API gets a custom Analytics visitor identifier, which has been set previously using setVisitorIdentifier.
Java
Syntax
Copied to your clipboardpublic static void getVisitorIdentifier(@NonNull final AdobeCallback<String> callback)
- callback is invoked with the visitor identifier value. When an AdobeCallbackWithError is provided, an AdobeError can be returned in the eventuality of an unexpected error or if the default timeout (5000ms) is met before the callback is returned with visitor identifier.
Example
Copied to your clipboardAnalytics.getVisitorIdentifier(new AdobeCallbackWithError<String>() {@Overridepublic void fail(AdobeError adobeError) {// Handle the error}@Overridepublic void call(String s) {// Handle the Visitor ID}});
Kotlin
Example
Copied to your clipboardAnalytics.getVisitorIdentifier(object: AdobeCallbackWithError<String> {override fun call(id: String?) {// Handle the Visitor ID}override fun fail(error: AdobeError?) {// Handle the error}})
For more information on using this API call, please read getVisitorIdentifierWithCompletionHandler.
Java
Syntax
Copied to your clipboardpublic static void getVisitorIdentifier(@NonNull final AdobeCallback<String> callback)
- callback is invoked with the visitor identifier value. When an AdobeCallbackWithError is provided, an AdobeError can be returned in the eventuality of an unexpected error or if the default timeout (5000ms) is met before the callback is returned with visitor identifier.
Example
Copied to your clipboardAnalytics.getVisitorIdentifier(new AdobeCallbackWithError<String>() {@Overridepublic void fail(AdobeError adobeError) {// Handle the error}@Overridepublic void call(String s) {// Handle the Visitor ID}});
Kotlin
Example
Copied to your clipboardAnalytics.getVisitorIdentifier(object: AdobeCallbackWithError<String> {override fun call(id: String?) {// Handle the Visitor ID}override fun fail(error: AdobeError?) {// Handle the error}})
For more information on using this API call, please read getVisitorIdentifierWithCompletionHandler.
getVisitorIdentifierWithCompletionHandler
Before using this API, see Identify unique visitors.
This API gets a custom Analytics visitor identifier, which has been set previously using setVisitorIdentifier. Callback with NSError if an unexpected error occurs or the request times out.
iOS
Swift
Syntax
Copied to your clipboardstatic func getVisitorIdentifier(completion: @escaping (String?, Error?) -> Void)
Example
Copied to your clipboardAnalytics.getVisitorIdentifier { (visitorIdentifier, error) in// Handle the error (if non-nil) or use the visitorIdentifier value}
Objective-C
Syntax
Copied to your clipboard+ (void) getVisitorIdentifier:^(NSString * _Nullable, NSError * _Nullable)completion
Example
Copied to your clipboard[AEPMobileAnalytics getVisitorIdentifier:^(NSString * _Nullable visitorIdentifier, NSError * _Nullable error) {// Handle the error (if non-nil) or use the visitorIdentifier value}];
Swift
Syntax
Copied to your clipboardstatic func getVisitorIdentifier(completion: @escaping (String?, Error?) -> Void)
Example
Copied to your clipboardAnalytics.getVisitorIdentifier { (visitorIdentifier, error) in// Handle the error (if non-nil) or use the visitorIdentifier value}
Objective-C
Syntax
Copied to your clipboard+ (void) getVisitorIdentifier:^(NSString * _Nullable, NSError * _Nullable)completion
Example
Copied to your clipboard[AEPMobileAnalytics getVisitorIdentifier:^(NSString * _Nullable visitorIdentifier, NSError * _Nullable error) {// Handle the error (if non-nil) or use the visitorIdentifier value}];
registerExtension
This API has been deprecated starting in v2.0.0 and removed in v3.0.0 of the Android mobile extension.
Use MobileCore.registerExtensions()
API instead.
Registers the Analytics extension with the Mobile Core SDK.
resetIdentities
Clears the identities stored in the Analytics extension - tracking identifier (AID)
and the custom visitor identifiers (VID)
stored in the Analytics extension and force deletes, without sending to Analytics, all hits being stored or batched on the SDK.
Support for this API was added in:
- Android Analytics version 1.2.9
- iOS AEPAnalytics version 3.0.3
See MobileCore.resetIdentities for more details.
sendQueuedHits
Sends all queued hits to Analytics, regardless of the current hit batch settings.
This method forces the library to send all hits in the offline queue, regardless of how many hits are currently queued.
Use caution when manually clearing the queue. This operation cannot be reverted.
setVisitorIdentifier
Before using this API, see Identify unique visitors.
Sets a custom Analytics visitor identifier. For more information, see Custom Visitor ID.
Java
Syntax
Copied to your clipboardpublic static void setVisitorIdentifier(@NonNull final String visitorID)
- visitorIdentifier is the new value for the visitor identifier.
Example
Copied to your clipboardAnalytics.setVisitorIdentifier("custom_identifier");
Kotlin
Example
Copied to your clipboardAnalytics.setVisitorIdentifier("custom_identifier");
Swift
Syntax
Copied to your clipboardstatic func setVisitorIdentifier(visitorIdentifier: String)
- visitorIdentifier is the new value for the visitor identifier.
Example
Copied to your clipboardAnalytics.setVisitorIdentifier(visitorIdentifier:"custom_identifier")
Objective-C
Syntax
Copied to your clipboard+ (void) setVisitorIdentifier:(NSString * _Nonnull)
Example
Copied to your clipboard[AEPMobileAnalytics setVisitorIdentifier:@"custom_identifier"];
Java
Syntax
Copied to your clipboardpublic static void setVisitorIdentifier(@NonNull final String visitorID)
- visitorIdentifier is the new value for the visitor identifier.
Example
Copied to your clipboardAnalytics.setVisitorIdentifier("custom_identifier");
Kotlin
Example
Copied to your clipboardAnalytics.setVisitorIdentifier("custom_identifier");
Swift
Syntax
Copied to your clipboardstatic func setVisitorIdentifier(visitorIdentifier: String)
- visitorIdentifier is the new value for the visitor identifier.
Example
Copied to your clipboardAnalytics.setVisitorIdentifier(visitorIdentifier:"custom_identifier")
Objective-C
Syntax
Copied to your clipboard+ (void) setVisitorIdentifier:(NSString * _Nonnull)
Example
Copied to your clipboard[AEPMobileAnalytics setVisitorIdentifier:@"custom_identifier"];