Hi,
I am currently working on the migration of ACP core and ACP analytics from 2.x to AEP 3.x. The migration guide says that the AEP analytics is removed and all 2.x workflows are supported via edge network or edge bridge. My question is how can I set the visitorIdentifier from React Native layer? I don't see relevant React Native API under API reference as well.
Thanks.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @Adobe_Shall_We ,
Thanks for your patience with my long reply!
Great question! Switching from ACP 2.x to AEP 3.x can be a bit confusing at first. Let’s talk about how you can set the visitorIdentifier in AEP 3.x since the old ACPAnalytics.setVisitorIdentifier method isn't around anymore.
Adobe has made things simpler in AEP 3.x with the Edge Network, which means some old methods, like setVisitorIdentifier, have been replaced. Now, you use the EdgeIdentity API for identity stuff.
Here’s a quick example if you’re using React Native:
First, make sure you’ve got the AEP SDKs installed. Then, you can follow the new steps to set the visitorIdentifier.
npm install @adobe/react-native-aep-core @adobe/react-native-aep-edge
Initialize the SDK: Set up the SDK in your main application file (typically App.js).
import { ACPCore, ACPMobileLogLevel, ACPMobilePrivacyStatus } from '@adobe/react-native-aep-core';
import { ACPEdge } from '@adobe/react-native-aep-edge';
ACPCore.setLogLevel(ACPMobileLogLevel.DEBUG);
ACPCore.setPrivacyStatus(ACPMobilePrivacyStatus.OPT_IN);
ACPCore.configureWithAppId("YOUR_APP_ID");
ACPEdge.registerExtension();
Set the Visitor Identifier: Use the EdgeIdentity API to manage and update identities. Here’s how you can do it:
import { ACPEdgeIdentity } from '@adobe/react-native-aep-edge';
const setVisitorIdentifier = async (visitorId) => {
try {
const identities = {
"identityType": "CUSTOMER_ID",
"id": visitorId,
"authenticatedState": "authenticated",
"primary": true
};
await ACPEdgeIdentity.updateIdentities([identities]);
console.log("Visitor identifier set successfully");
} catch (error) {
console.error("Error setting visitor identifier: ", error);
}
};
// Usage
setVisitorIdentifier("YOUR_VISITOR_ID");
EdgeIdentity API - This new API allows you to manage user identities in a more streamlined way. By using updateIdentities, you can set various types of identifiers, including custom identifiers like visitorId.
Identity Map - The identity map you pass to updateIdentities should include the type of identity, the identifier itself, the authentication state, and whether it’s the primary identifier.
Hope this clears things up!
Thank you for explaining this so well. If I plan to use 6.x which I believe is the latest, can I set the visitor Id directly like this? Thanks in advance!
let identityItem = new IdentityItem("SomeHashedVisitorId");
let map = new IdentityMap();
map.addItem(identityItem, "v_id");
Identity.updateIdentities(map);
Views
Replies
Total Likes
Hello @Adobe_Shall_We ,
You're welcome!
Yes, you can use the mentioned code to set the Visitor Id. Here are the imports you need to use which is missed in your code.
import { Identity } from '@adobe/react-native-aepedgeidentity';
import { IdentityItem, IdentityMap } from '@adobe/react-native-aepedgeidentity';
Let me know if you have any other questions or need further help!
Curious to know whey AEP3.0 instead if the latest v5?
Since you mentioned about using Edge Bridge, SDK v5 has a more simple data workflow to AA and you no longer have to do Data Prep in Data Stream, this is a big plus especially when you have to deal with eCommerce product string.
Views
Replies
Total Likes
Thank you for the question. I am using ACP prefixed libraries. As per the migration guide for Adobe Experience Platform SDKs for iOS and Android, I have to be on 3.x. But I guess you are right I can migrate to the Experience Platform SDK libraries (AEP) for React Native from 2.x to 6.x? Please correct me if I am wrong, it's my first time working in this space and using Adobe.
Thanks in advance.
Views
Replies
Total Likes
I think it should be fine and recommended to migrate to the latest AEP React Native v6.
Assume you want to keep using trackState/Action, the Analytics extension is no longer supported, and you have to use the new Edge Bridge extension, and you need to config a Data Stream in AEP for passing data to AA and set it to your Launch property. And with the latest version, no mapping is needed in the Data Stream.
Hope it helps.
Thank you @Hey_John for all the insights!
Views
Replies
Total Likes
Views
Likes
Replies