Edit in GitHubLog an issue

Java

  1. Add the Mobile Core and Analytics extensions to your project using the app's Gradle file.
Copied to your clipboard
implementation 'com.adobe.marketing.mobile:sdk-core:1.+'
implementation 'com.adobe.marketing.mobile:analytics:1.+'
  1. Import the Analytics extension in your application's main activity.
Copied to your clipboard
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Analytics;
  1. Add the Mobile Core and Analytics extensions to your project using Cocoapods.
  2. Add the following pods in your Podfile:
Copied to your clipboard
pod 'ACPCore'
pod 'ACPAnalytics'
  1. Import the Analytics and Identity libraries:

Swift

Copied to your clipboard
import ACPCore
import ACPAnalytics

Objective-C

Copied to your clipboard
#import "ACPCore.h"
#import "ACPAnalytics.h"
#import "ACPIdentity.h"

JavaScript

  1. Install Adobe Analytics.
Copied to your clipboard
npm install @adobe/react-native-acpanalytics
  1. 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 clipboard
react-native link @adobe/react-native-acpanalytics

If you are using iOS and cocoapods, run:

Copied to your clipboard
cd ios/ && pod install
  1. Import the extension.
Copied to your clipboard
import {ACPAnalytics} from '@adobe/react-native-acpanalytics';
  1. Get the extension version.
Copied to your clipboard
ACPAnalytics.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPAnalytics version: " + version));

Flutter

  1. Install Analytics.

Instructions on installing the Analytics SDK in Flutter can be found in the official Flutter documentation.

  1. Import the extension.
Copied to your clipboard
import 'package:flutter_acpanalytics/flutter_acpanalytics.dart';
  1. Get the extension version.
Copied to your clipboard
String version = await FlutterACPAnalytics.extensionVersion;

Cordova

  1. After creating your Cordova app and adding the Android and iOS platforms, add the Analytics extension.
Copied to your clipboard
cordova plugin add https://github.com/adobe/cordova-acpanalytics.git
  1. Get the extension version.
Copied to your clipboard
ACPAnalytics.extensionVersion(function(version) {
console.log("ACPAnalytics version: " + version);
}, function(error) {
console.log(error);
});

C#

  1. After importing the ACPAnalytics.unitypackage, add the Analytics extension for Unity.
Copied to your clipboard
using com.adobe.marketing.mobile;
  1. Get the extension version.
Copied to your clipboard
ACPAnalytics.extensionVersion();

C#

  1. After adding the iOS or Android ACPAnalytics NuGet package, add the Analytics extension.
Copied to your clipboard
using Com.Adobe.Marketing.Mobile;
  1. Get the extension version.
Copied to your clipboard
ACPAnalytics.ExtensionVersion();

Java

The following sample shows how to set up methods that call the setApplication() method in the onCreate() method:

Copied to your clipboard
public class MobileApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
MobileCore.configureWithAppID("yourAppId");
try {
Analytics.registerExtension(); //Register Analytics with Mobile Core
Identity.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 clipboard
func 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 clipboard
using 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 update
void Start()
{
ACPAnalytics.registerExtension();
ACPCore.Start(HandleStartAdobeCallback);
}
}

C#

iOS

Register the Analytics extension in your app's FinishedLaunching() function:

Copied to your clipboard
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
ACPAnalytics.RegisterExtension();
// start core
ACPCore.Start(startCallback);
return base.FinishedLaunching(app, options);
}
private void startCallback()
{
// set launch config
ACPCore.ConfigureWithAppID("yourAppId");
}

Android

Register the Analytics extension in your app's OnCreate() function:

Copied to your clipboard
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
ACPAnalytics.RegisterExtension();
// start core
ACPCore.Start(new CoreStartCompletionCallback());
}
class CoreStartCompletionCallback : Java.Lang.Object, IAdobeCallback
{
public void Call(Java.Lang.Object callback)
{
// set launch config
ACPCore.ConfigureWithAppID("yourAppId");
}
}

Java

Syntax

Copied to your clipboard
cdata.put("&&events", "event1:12341234");

Example

Copied to your clipboard
//create a context data dictionary
HashMap cdata = new HashMap<String, Object>();
// add events
cdata.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 dictionary
NSMutableDictionary *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 clipboard
var contextData = {"eventN:serial number": "&&events"};

Example

Copied to your clipboard
// create a context data dictionary and add events
var 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 clipboard
var contextData = {"eventN:serial number": "&&events"};

Example

Copied to your clipboard
// create a context data dictionary and add events
var 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 clipboard
var contextData = {"eventN:serial number": "&&events"};

Example

Copied to your clipboard
// create a context data dictionary and add events
var 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 clipboard
var contextData = new Dictionary<string, string>();
contextData.Add("key", "trackAction");

Example

Copied to your clipboard
// create a context data dictionary and add events
var 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 clipboard
var contextData = new NSMutableDictionary<NSString, NSString>
{
["&&events"] = new NSString("eventN:serial number")
};

iOS example

Copied to your clipboard
// create a context data dictionary and add events
var 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 clipboard
var contextData = new Dictionary<string, string>();
contextData.Add("&&events", "event1:12341234");

Android example

Copied to your clipboard
// create a context data dictionary and add events
var 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 clipboard
HashMap<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 clipboard
let 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 clipboard
NSDictionary *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 clipboard
ACPCore.updateConfiguration({"analytics.server": "sample.analytics.tracking.server",
"analytics.rsids": "rsid1,rsid2",
"analytics.batchLimit": 10,
"analytics.offlineEnabled": true});

Dart

Example

Copied to your clipboard
FlutterACPCore.updateConfiguration({"analytics.server": "sample.analytics.tracking.server",
"analytics.rsids": "rsid1,rsid2",
"analytics.batchLimit": 10,
"analytics.offlineEnabled": true});

Cordova

Example

Copied to your clipboard
ACPCore.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 clipboard
var 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 clipboard
var 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 clipboard
var 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);
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.