Java
- Add the Mobile Core and Analytics extensions to your project using the app's Gradle file.
Copied to your clipboardimplementation 'com.adobe.marketing.mobile:sdk-core:1.+'implementation 'com.adobe.marketing.mobile:analytics:1.+'
- Import the Analytics extension in your application's main activity.
Copied to your clipboardimport com.adobe.marketing.mobile.MobileCore;import com.adobe.marketing.mobile.Analytics;
- Add the Mobile Core and Analytics extensions to your project using Cocoapods.
- Add the following pods in your
Podfile
:
Copied to your clipboardpod 'ACPCore'pod 'ACPAnalytics'
- Import the Analytics and Identity libraries:
Swift
Copied to your clipboardimport ACPCoreimport ACPAnalytics
Objective-C
Copied to your clipboard#import "ACPCore.h"#import "ACPAnalytics.h"#import "ACPIdentity.h"
JavaScript
- Install Adobe Analytics.
Copied to your clipboardnpm install @adobe/react-native-acpanalytics
- Link the module and the application.
For React Native versions 0.6 and above, you can use the CLI autolink feature to link the module while building the app.
For React Native versions less than or equal to 0.59, you can use the following scripts:
Copied to your clipboardreact-native link @adobe/react-native-acpanalytics
If you are using iOS and cocoapods
, run:
Copied to your clipboardcd ios/ && pod install
- Import the extension.
Copied to your clipboardimport {ACPAnalytics} from '@adobe/react-native-acpanalytics';
- Get the extension version.
Copied to your clipboardACPAnalytics.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPAnalytics version: " + version));
Flutter
- Install Analytics.
Instructions on installing the Analytics SDK in Flutter can be found in the official Flutter documentation.
- Import the extension.
Copied to your clipboardimport 'package:flutter_acpanalytics/flutter_acpanalytics.dart';
- Get the extension version.
Copied to your clipboardString version = await FlutterACPAnalytics.extensionVersion;
Cordova
- After creating your Cordova app and adding the Android and iOS platforms, add the Analytics extension.
Copied to your clipboardcordova plugin add https://github.com/adobe/cordova-acpanalytics.git
- Get the extension version.
Copied to your clipboardACPAnalytics.extensionVersion(function(version) {console.log("ACPAnalytics version: " + version);}, function(error) {console.log(error);});
C#
- After importing the ACPAnalytics.unitypackage, add the Analytics extension for Unity.
Copied to your clipboardusing com.adobe.marketing.mobile;
- Get the extension version.
Copied to your clipboardACPAnalytics.extensionVersion();
C#
- After adding the iOS or Android ACPAnalytics NuGet package, add the Analytics extension.
Copied to your clipboardusing Com.Adobe.Marketing.Mobile;
- Get the extension version.
Copied to your clipboardACPAnalytics.ExtensionVersion();
Java
The following sample shows how to set up methods that call the setApplication() method in the onCreate()
method:
Copied to your clipboardpublic class MobileApp extends Application {@Overridepublic void onCreate() {super.onCreate();MobileCore.setApplication(this);MobileCore.configureWithAppID("yourAppId");try {Analytics.registerExtension(); //Register Analytics with Mobile CoreIdentity.registerExtension();MobileCore.start(null);} catch (Exception e) {//Log the exception}}}
Analytics depends on the Identity extension and is automatically included in Core by Maven. When manually installing the Analytics extension, ensure that you add the identity-1.x.x.aar
library to your project.
Swift
In your app's _:didFinishLaunchingWithOptions
function, register the Audience Manager extension with the Mobile Core:
Copied to your clipboardfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {ACPCore.configure(withAppId: "yourAppId")ACPAnalytics.registerExtension()ACPIdentity.registerExtension()ACPCore.start(nil)// Override point for customization after application launch.return true;}
Objective-C
In your app's application:didFinishLaunchingWithOptions
, register Analytics with Mobile Core:
Copied to your clipboard- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[ACPCore configureWithAppId:@"yourAppId"];[ACPAnalytics registerExtension];[ACPIdentity registerExtension];[ACPCore start:nil];// Override point for customization after application launch.return YES;}
Analytics depends on the Identity extension and is automatically included in the Core pod. When installing the Analytics extension manually, ensure that you added the libACPIdentity_iOS.a
library to your project.
JavaScript
When using React Native, register Analytics with Mobile Core in native code as shown on the Android and iOS tabs.
Dart
When using Flutter, register Analytics with Mobile Core in native code as shown on the Android and iOS tabs.
Cordova
When using Cordova, register Analytics with Mobile Core in native code as shown on the Android and iOS tabs.
C#
Register the extension in the start()
function:
Copied to your clipboardusing com.adobe.marketing.mobile;using using AOT;public class MainScript : MonoBehaviour{[MonoPInvokeCallback(typeof(AdobeStartCallback))]public static void HandleStartAdobeCallback(){ACPCore.ConfigureWithAppID("1423ae38-8385-8963-8693-28375403491d");}// Start is called before the first frame updatevoid Start(){ACPAnalytics.registerExtension();ACPCore.Start(HandleStartAdobeCallback);}}
C#
iOS
Register the Analytics extension in your app's FinishedLaunching()
function:
Copied to your clipboardpublic override bool FinishedLaunching(UIApplication app, NSDictionary options){global::Xamarin.Forms.Forms.Init();LoadApplication(new App());ACPAnalytics.RegisterExtension();// start coreACPCore.Start(startCallback);return base.FinishedLaunching(app, options);}private void startCallback(){// set launch configACPCore.ConfigureWithAppID("yourAppId");}
Android
Register the Analytics extension in your app's OnCreate()
function:
Copied to your clipboardprotected override void OnCreate(Bundle savedInstanceState){base.OnCreate(savedInstanceState);global::Xamarin.Forms.Forms.Init(this, savedInstanceState);LoadApplication(new App());ACPAnalytics.RegisterExtension();// start coreACPCore.Start(new CoreStartCompletionCallback());}class CoreStartCompletionCallback : Java.Lang.Object, IAdobeCallback{public void Call(Java.Lang.Object callback){// set launch configACPCore.ConfigureWithAppID("yourAppId");}}
Java
Syntax
Copied to your clipboardcdata.put("&&events", "event1:12341234");
Example
Copied to your clipboard//create a context data dictionaryHashMap cdata = new HashMap<String, Object>();// add eventscdata.put("&&events", "event1:12341234");// send a tracking call - use either a trackAction or TrackState call.// trackAction example:MobileCore.trackAction("Action Name", cdata);// trackState example:MobileCore.trackState("State Name", cdata);
Objective-C
Syntax
Copied to your clipboard[contextData setObject:@"eventN:serial number" forKey:@"&&events"];
Example
Copied to your clipboard//create a context data dictionaryNSMutableDictionary *contextData = [NSMutableDictionary dictionary];// add events[contextData setObject:@"event1:12341234" forKey:@"&&events"];// send the tracking call - use either a trackAction or trackState call.// trackAction example:[ACPCore trackAction:@"Action Name" data:contextData];// trackState example:[ACPCore trackState:@"State Name" data:contextData];
JavaScript
Syntax
Copied to your clipboardvar contextData = {"eventN:serial number": "&&events"};
Example
Copied to your clipboard// create a context data dictionary and add eventsvar contextData = {"event1:12341234": "&&events"};// send the tracking call - use either a trackAction or trackState call.// trackAction example:ACPCore.trackAction("Action Name", contextData);// trackState example:ACPCore.trackState("State Name", contextData);
Dart
Syntax
Copied to your clipboardvar contextData = {"eventN:serial number": "&&events"};
Example
Copied to your clipboard// create a context data dictionary and add eventsvar contextData = {"event1:12341234": "&&events"};// send the tracking call - use either a trackAction or trackState call.// trackAction example:FlutterACPCore.trackAction("Action Name", data: contextData);// trackState example:FlutterACPCore.trackState("State Name", data: contextData);
Cordova
Syntax
Copied to your clipboardvar contextData = {"eventN:serial number": "&&events"};
Example
Copied to your clipboard// create a context data dictionary and add eventsvar contextData = {"event1:12341234": "&&events"};// send the tracking call - use either a trackAction or trackState call.// trackAction example:ACPCore.trackAction("Action Name", contextData, function(handleCallback) {console.log("AdobeExperenceSDK: Track action success: " + handleCallback);}, function(handleError) {console.log("AdobeExperenceSDK: Failed to track action: " + handleError);});// trackState example:ACPCore.trackState("State Name", contextData, function(handleCallback) {console.log("AdobeExperenceSDK: Track state success: " + handleCallback);}, function(handleError) {console.log("AdobeExperenceSDK: Failed to track state: " + handleError);});
C#
Syntax
Copied to your clipboardvar contextData = new Dictionary<string, string>();contextData.Add("key", "trackAction");
Example
Copied to your clipboard// create a context data dictionary and add eventsvar contextData = new Dictionary<string, string>();contextData.Add("key", "trackAction");// send the tracking call - use either a trackAction or trackState call.// trackAction example:ACPCore.TrackAction("Action Name", contextData);// trackState example:ACPCore.TrackState("State Name", contextData);
C#
iOS syntax
Copied to your clipboardvar contextData = new NSMutableDictionary<NSString, NSString>{["&&events"] = new NSString("eventN:serial number")};
iOS example
Copied to your clipboard// create a context data dictionary and add eventsvar contextData = new NSMutableDictionary<NSString, NSString>{["&&events"] = new NSString("event1:12341234")};// send the tracking call - use either a trackAction or trackState call.// trackAction example:ACPCore.TrackAction("Action Name", contextData);// trackState example:ACPCore.TrackState("State Name", contextData);
Android syntax
Copied to your clipboardvar contextData = new Dictionary<string, string>();contextData.Add("&&events", "event1:12341234");
Android example
Copied to your clipboard// create a context data dictionary and add eventsvar contextData = new Dictionary<string, string>();contextData.Add("&&events", "event1:12341234");// send the tracking call - use either a trackAction or trackState call.// trackAction example:ACPCore.TrackAction("Action Name", contextData);// trackState example:ACPCore.TrackState("State Name", contextData);
Java
Example
Copied to your clipboardHashMap<String, Object> data = new HashMap<String, Object>();data.put("analytics.server", "sample.analytics.tracking.server");data.put("analytics.rsids", "rsid1,rsid2");data.put("analytics.batchLimit", 10);data.put("analytics.offlineEnabled", true);MobileCore.updateConfiguration(data);
Swift
Example
Copied to your clipboardlet updatedConfig = ["analytics.server":"sample.analytics.tracking.server","analytics.rsids":"rsid1,rsid2","analytics.batchLimit":10,"analytics.offlineEnabled":true]ACPCore.updateConfiguration(updatedConfig)
Objective-C
Example
Copied to your clipboardNSDictionary *updatedConfig = @{@"analytics.server":@"sample.analytics.tracking.server",@"analytics.rsids":@"rsid1,rsid2",@"analytics.batchLimit":@(10),@"analytics.offlineEnabled":@YES};[ACPCore updateConfiguration:updatedConfig];
JavaScript
Example
Copied to your clipboardACPCore.updateConfiguration({"analytics.server": "sample.analytics.tracking.server","analytics.rsids": "rsid1,rsid2","analytics.batchLimit": 10,"analytics.offlineEnabled": true});
Dart
Example
Copied to your clipboardFlutterACPCore.updateConfiguration({"analytics.server": "sample.analytics.tracking.server","analytics.rsids": "rsid1,rsid2","analytics.batchLimit": 10,"analytics.offlineEnabled": true});
Cordova
Example
Copied to your clipboardACPCore.updateConfiguration({"analytics.server": "sample.analytics.tracking.server","analytics.rsids": "rsid1,rsid2","analytics.batchLimit": 10,"analytics.offlineEnabled": true}, function(handleCallback) {console.log("AdobeExperenceSDK: Analytics configuration update success: " + handleCallback);}, function(handleError) {console.log("AdobeExperenceSDK: Failed to update analytics configuration: " + handleError);});
C#
Example
Copied to your clipboardvar dict = new Dictionary<string, object>();dict.Add("analytics.server": "sample.analytics.tracking.server");dict.Add("analytics.rsids": "rsid1,rsid2");dict.Add("analytics.batchLimit": 10);dict.Add("analytics.offlineEnabled": true);ACPCore.UpdateConfiguration(dict);
C#
iOS example
Copied to your clipboardvar config = new NSMutableDictionary<NSString, NSObject>{["analytics.server"] = new NSString("sample.analytics.tracking.server"),["analytics.rsids"] = new NSString("rsid1,rsid2"),["analytics.batchLimit"] = new NSNumber(10),["analytics.offlineEnabled"] = new NSNumber(true)};ACPCore.UpdateConfiguration(config);
Android example
Copied to your clipboardvar config = new Dictionary<string, Java.Lang.Object>();config.Add("analytics.server", "sample.analytics.tracking.server");config.Add("analytics.rsids", "rsid1,rsid2");config.Add("analytics.batchLimit", 10);config.Add("analytics.offlineEnabled", true);ACPCore.UpdateConfiguration(config);