Adobe Mobile Library (v4) to Experience Platform Analytics migration
Configuration
The Adobe Experience Platform Analytics extension uses tags to configure the Experience Platform SDKs. This replaces the ADBMobileConfig.json which the Mobile Services SDK used for configuration. To get started with the AEP SDKs:
- Create a mobile property on tags.
See Set up a mobile property for more information. - Configure your mobile app with the create mobile property.
The AEP Mobile Core extension provides general functionality required by all the Adobe AEP extensions. The Configuration extension is built into the Mobile Core and contains the configureWithAppId API. This API is used to link the tag mobile property with your mobile app. The documentation for this API can be seen at the Configuration API Reference page. A code sample showing the usage of this API is provided below. - Once all the Platform extensions are imported and configured correctly, remove the v4 Mobile SDK dependency.
This step is mandatory and a mix of v4 and AEP API calls is not supported.
If using Cocoapods, remove the v4 Mobile SDK dependency from the Podfile:
Copied to your clipboardtarget 'YourTarget' dopod 'AdobeMobileSDK'...end
Alternatively, if the v4 Mobile SDK library is linked in Xcode, select the application target and go to Build Phases
, then Link Binary With Libraries
and remove AdobeMobileLibrary.a
.
If using Gradle, remove the v4 Mobile SDK dependency:
Gradle
Copied to your clipboarddependencies {implementation 'com.adobe.mobile:adobeMobileLibrary:4.18.2'...}
Alternatively, if the v4 Mobile SDK library is linked as a jar, search for adobeMobileLibrary
in your project and remove the jar file.
If using Cocoapods, remove the v4 Mobile SDK dependency from the Podfile:
Copied to your clipboardtarget 'YourTarget' dopod 'AdobeMobileSDK'...end
Alternatively, if the v4 Mobile SDK library is linked in Xcode, select the application target and go to Build Phases
, then Link Binary With Libraries
and remove AdobeMobileLibrary.a
.
Analytics Migration Overview
For an overview of the API mapping between the Mobile Services SDK and Adobe Experience Platform SDKs, see the API Change Log. This section describes the Analytics-specific changes made with the AEP Analytics extension.
Deprecated API
API | Notes |
---|---|
trackActionFromBackground | Deprecated |
trackLocation:data: | This functionality is available in the Places extension. |
trackBeacon:Data: | Support modified. See guide. |
trackingClearCurrentBeacon | Support modified. See guide. |
trackLifetimeValueIncrease:data: | This functionality can be recreated using the Analytics and User Profile extensions. |
trackTimedActionStart: | This functionality can be recreated using the Analytics and User Profile extensions. |
trackTimedActionUpdate: | This functionality can be recreated using the Analytics and User Profile extensions. |
trackTimedActionEnd: | This functionality can be recreated using the Analytics and User Profile extensions. |
trackTimedActionExists: | This functionality can be recreated using the Analytics and User Profile extensions. |
Experience Platform extensions installation and setup
Register the extensions and link the app to the configuration created with Data Collection tags
In your app's Application class add the mobile extension registration and configuration code:
Java
Copied to your clipboardimport com.adobe.marketing.mobile.MobileCore;import com.adobe.marketing.mobile.Analytics;import com.adobe.marketing.mobile.Identity;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);MobileCore.setApplication(getApplication());MobileCore.registerExtensions(Arrays.asList(Analytics.EXTENSION,Identity.EXTENSION), value -> {// add your Environment file ID from Environments tab in Data Collection tags.MobileCore.configureWithAppID("your-environment-file-id");});}
Swift
Copied to your clipboardimport AEPCoreimport AEPIdentityimport AEPAnalyticsfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {MobileCore.registerExtensions([Analytics.self, Identity.self], {// Use the environment file id assigned to this application in Data Collection UIMobileCore.configureWith(appId: "your-environment-file-id")})return true}
Objective-C
Copied to your clipboard// AppDelegate.h@import AEPCore;@import AEPIdentity;@import AEPAnalytics;// AppDelegate.m- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[AEPMobileCore registerExtensions:@[AEPMobileAnalytics.class, AEPMobileIdentity.class] completion:^{// Use the environment file id assigned to this application in Data Collection UI[AEPMobileCore configureWithAppId: @"your-environment-file-id"];}];return YES;}
Java
Copied to your clipboardimport com.adobe.marketing.mobile.MobileCore;import com.adobe.marketing.mobile.Analytics;import com.adobe.marketing.mobile.Identity;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);MobileCore.setApplication(getApplication());MobileCore.registerExtensions(Arrays.asList(Analytics.EXTENSION,Identity.EXTENSION), value -> {// add your Environment file ID from Environments tab in Data Collection tags.MobileCore.configureWithAppID("your-environment-file-id");});}
Swift
Copied to your clipboardimport AEPCoreimport AEPIdentityimport AEPAnalyticsfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {MobileCore.registerExtensions([Analytics.self, Identity.self], {// Use the environment file id assigned to this application in Data Collection UIMobileCore.configureWith(appId: "your-environment-file-id")})return true}
Objective-C
Copied to your clipboard// AppDelegate.h@import AEPCore;@import AEPIdentity;@import AEPAnalytics;// AppDelegate.m- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[AEPMobileCore registerExtensions:@[AEPMobileAnalytics.class, AEPMobileIdentity.class] completion:^{// Use the environment file id assigned to this application in Data Collection UI[AEPMobileCore configureWithAppId: @"your-environment-file-id"];}];return YES;}
For more details, see Add Analytics to your application.
API changes
Track app states and actions
Adobe Mobile Library (v4)
Java
The Adobe Mobile Library (v4) syntax and usage examples for these API are:
Copied to your clipboard// syntaxpublic static void trackState(final String state, final Map<String, Object> contextData)// usageAnalytics.trackState("MainPage", new HashMap<String, Object>() {{put("firstVisit", true);}});
Copied to your clipboard// syntaxpublic static void trackAction(final String action, final Map<String, Object> contextData)// usageAnalytics.trackAction("linkClicked", new HashMap<String, Object>() {{put("url", "https://www.adobe.com");}});
Objective-C
The Adobe Mobile Library (v4) syntax and usage examples for these API are:
Copied to your clipboard// syntax+ (void) trackState:(NSString *)state data:(NSDictionary *)data;// usage[ADBMobile trackState:@"MainPage" data:@{@"firstVisit":@true}];
Copied to your clipboard// syntax+ (void) trackAction:(NSString *)action data:(NSDictionary *)data;// usage[ADBMobile trackAction:@"linkClicked" data:@{@"url":@"https://www.adobe.com"}];
Java
The Adobe Mobile Library (v4) syntax and usage examples for these API are:
Copied to your clipboard// syntaxpublic static void trackState(final String state, final Map<String, Object> contextData)// usageAnalytics.trackState("MainPage", new HashMap<String, Object>() {{put("firstVisit", true);}});
Copied to your clipboard// syntaxpublic static void trackAction(final String action, final Map<String, Object> contextData)// usageAnalytics.trackAction("linkClicked", new HashMap<String, Object>() {{put("url", "https://www.adobe.com");}});
Objective-C
The Adobe Mobile Library (v4) syntax and usage examples for these API are:
Copied to your clipboard// syntax+ (void) trackState:(NSString *)state data:(NSDictionary *)data;// usage[ADBMobile trackState:@"MainPage" data:@{@"firstVisit":@true}];
Copied to your clipboard// syntax+ (void) trackAction:(NSString *)action data:(NSDictionary *)data;// usage[ADBMobile trackAction:@"linkClicked" data:@{@"url":@"https://www.adobe.com"}];
Experience Platform Mobile SDKs
The Mobile SDKs have moved the trackAction
and trackState
APIs to the MobileCore extension. In addition, the context data Map has been changed from <String, Object>
to <String, String>
. The syntax is:
Java
Copied to your clipboard// syntaxpublic static void trackState(final String state, final Map<String, String> contextData)// usageMobileCore.trackState("MainPage", new HashMap<String, String>() {{put("firstVisit", "true");}});
Copied to your clipboard// syntaxpublic static void trackAction(final String action, final Map<String, String> contextData)// usageMobileCore.trackAction("linkClicked", new HashMap<String, String>() {{put("url", "https://www.adobe.com");}});
The Mobile SDKs have moved the trackAction
and trackState
APIs to the MobileCore extension. The syntax is:
Copied to your clipboard@objc(trackAction:data:)static func track(action: String?, data: [String: Any]?)
Copied to your clipboard@objc(trackState:data:)static func track(state: String?, data: [String: Any]?)
The usage examples are:
Swift
Copied to your clipboardMobileCore.track(state: "MainPage", data: ["firstVisit": "true"])MobileCore.track(action: "linkClicked", data: ["url": "https://www.adobe.com"])
Objective-C
Copied to your clipboard[AEPMobileCore trackState:@"MainPage" data:@{@"firstVisit":@"true"}];[AEPMobileCore trackAction:@"linkClicked" data:@{@"url":@"https://www.adobe.com"}];
The Mobile SDKs have moved the trackAction
and trackState
APIs to the MobileCore extension. In addition, the context data Map has been changed from <String, Object>
to <String, String>
. The syntax is:
Java
Copied to your clipboard// syntaxpublic static void trackState(final String state, final Map<String, String> contextData)// usageMobileCore.trackState("MainPage", new HashMap<String, String>() {{put("firstVisit", "true");}});
Copied to your clipboard// syntaxpublic static void trackAction(final String action, final Map<String, String> contextData)// usageMobileCore.trackAction("linkClicked", new HashMap<String, String>() {{put("url", "https://www.adobe.com");}});
The Mobile SDKs have moved the trackAction
and trackState
APIs to the MobileCore extension. The syntax is:
Copied to your clipboard@objc(trackAction:data:)static func track(action: String?, data: [String: Any]?)
Copied to your clipboard@objc(trackState:data:)static func track(state: String?, data: [String: Any]?)
The usage examples are:
Swift
Copied to your clipboardMobileCore.track(state: "MainPage", data: ["firstVisit": "true"])MobileCore.track(action: "linkClicked", data: ["url": "https://www.adobe.com"])
Objective-C
Copied to your clipboard[AEPMobileCore trackState:@"MainPage" data:@{@"firstVisit":@"true"}];[AEPMobileCore trackAction:@"linkClicked" data:@{@"url":@"https://www.adobe.com"}];
Privacy status changes in the Experience Platform SDK
The privacy APIs setPrivacyStatus
and getPrivacyStatus
can be found in the Mobile Core. Similar to the v4 SDK, the Analytics extension will follow these behaviors depending on the privacy status set:
- Opted in: Analytics hits will be sent.
- Unknown: Analytics hits will be queued.
- Opted out: Analytics hits will be dropped.
Experience Platform Mobile SDKs
Java
The usage example for the setPrivacyStatus
API is:
Copied to your clipboardMobileCore.setPrivacyStatus(MobilePrivacyStatus.OPT_IN);MobileCore.setPrivacyStatus(MobilePrivacyStatus.OPT_OUT);MobileCore.setPrivacyStatus(MobilePrivacyStatus.UNKNOWN);
The usage example for the getPrivacyStatus
API is:
Copied to your clipboardMobileCore.getPrivacyStatus(new AdobeCallback<MobilePrivacyStatus>() {@Overridepublic void call(MobilePrivacyStatus status) {// handle current privacy status}});
The usage example for getPrivacyStatus
is:
Swift
Copied to your clipboardMobileCore.getPrivacyStatus(completion: ({ status in// handle current privacy statusswitch status {case PrivacyStatus.optedIn: print("Privacy Status: Opt-In")case PrivacyStatus.optedOut: print("Privacy Status: Opt-Out")case PrivacyStatus.unknown: print("Privacy Status: Unknown")default: break}})
Objective-C
Copied to your clipboard[AEPMobileCore getPrivacyStatus:^(AEPPrivacyStatus status) {switch (status) {case AEPPrivacyStatusOptedIn: NSLog(@"Privacy Status: Opt-In");case AEPPrivacyStatusOptedOut: NSLog(@"Privacy Status: Opt-Out");case AEPPrivacyStatusUnknown: NSLog(@"Privacy Status: Unknown");default: break;}}];
Java
The usage example for the setPrivacyStatus
API is:
Copied to your clipboardMobileCore.setPrivacyStatus(MobilePrivacyStatus.OPT_IN);MobileCore.setPrivacyStatus(MobilePrivacyStatus.OPT_OUT);MobileCore.setPrivacyStatus(MobilePrivacyStatus.UNKNOWN);
The usage example for the getPrivacyStatus
API is:
Copied to your clipboardMobileCore.getPrivacyStatus(new AdobeCallback<MobilePrivacyStatus>() {@Overridepublic void call(MobilePrivacyStatus status) {// handle current privacy status}});
The usage example for getPrivacyStatus
is:
Swift
Copied to your clipboardMobileCore.getPrivacyStatus(completion: ({ status in// handle current privacy statusswitch status {case PrivacyStatus.optedIn: print("Privacy Status: Opt-In")case PrivacyStatus.optedOut: print("Privacy Status: Opt-Out")case PrivacyStatus.unknown: print("Privacy Status: Unknown")default: break}})
Objective-C
Copied to your clipboard[AEPMobileCore getPrivacyStatus:^(AEPPrivacyStatus status) {switch (status) {case AEPPrivacyStatusOptedIn: NSLog(@"Privacy Status: Opt-In");case AEPPrivacyStatusOptedOut: NSLog(@"Privacy Status: Opt-Out");case AEPPrivacyStatusUnknown: NSLog(@"Privacy Status: Unknown");default: break;}}];