Skip to content

Commit

Permalink
Merge pull request #569 from calebk1/mob-20772
Browse files Browse the repository at this point in the history
MOB-20772 - Add tutorial for Identity in Mobile Core
  • Loading branch information
calebk1 authored Apr 24, 2024
2 parents 2870caa + 937b161 commit b056f8c
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 197 deletions.
14 changes: 12 additions & 2 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,18 @@ module.exports = {
path: "/home/base/mobile-core/identity/api-reference"
},
{
title: "Push identifier sync",
path: "/home/base/mobile-core/identity/push-sync"
title: "Tutorials",
path: "/home/base/mobile-core/identity/tutorials",
pages: [
{
title: "Mobile to web identity sharing",
path: "/home/base/mobile-core/identity/tutorials/id-sharing"
},
{
title: "Push identifier sync",
path: "/home/base/mobile-core/identity/tutorials/push-sync"
}
]
}
]
},
Expand Down
44 changes: 0 additions & 44 deletions src/pages/home/base/mobile-core/identity/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,47 +72,3 @@ Flutter
Previously known as MCID/MID/MCMID, the Experience Cloud ID (ECID) is a 38 character ID that uniquely identifies each visitor in the Adobe Experience Platform.

After the configuration is complete, an ECID is generated and, where applicable, is included on all Analytics and Audience Manager hits. Other IDs, such as custom and automatically-generated IDs, continue to be sent with each hit.

## Visitor tracking between an app and the mobile web

If your app opens mobile web content, you need to ensure that visitors are not identified separately as they move between the native and mobile web.

### Visitor IDs in apps

The Mobile SDK generates a unique visitor ID when the app is installed. This ECID is stored in persistent memory on the mobile device and is sent with every hit. The ECID is removed when the user uninstalls the app or when the user sets the Mobile SDK global privacy status to `optedout`.

<InlineAlert variant="info" slots="text"/>

When the Mobile SDK privacy status is set to `optedout`, and the ECID is removed, a new unique visitor ID (ECID) is generated when the user sets the global privacy status to `optedin`.

<InlineAlert variant="info" slots="text"/>

App visitor IDs persist through upgrades.

### Visitor IDs in the mobile web

Typical mobile web implementations use the same standard analytics `s_code.js` or `AppMeasurement.js` that is used in desktop sites. The JavaScript libraries have their own methods of generating unique visitor IDs, which causes a different visitor ID to be generated when you open mobile web content from your app.

To use the same visitor ID in the app and mobile web and pass the visitor ID to the mobile web in the URL, complete the following steps:

### Implementing visitor tracking between an app and the mobile web

<TabsBlock orientation="horizontal" slots="heading, content" repeat="2"/>

Android

<Tabs query="platform=android&task=implement"/>

iOS

<Tabs query="platform=ios&task=implement"/>

<!--- React Native
<Tabs query="platform=react-native&task=implement"/>
Flutter
<Tabs query="platform=flutter&task=implement"/> --->

The ID service code on the destination domain extracts the ECID from the URL instead of sending a request to Adobe for a new ID. The ID service code on the destination page uses this ECID to track the visitor. On hits from the mobile web content, verify that the `mid` parameter exists on each hit, and that this value matches the `mid`value that is being sent by the app code.
148 changes: 148 additions & 0 deletions src/pages/home/base/mobile-core/identity/tabs/id-sharing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
---
noIndex: true
---

<Variant platform="android" task="implement" repeat="5"/>

#### Java

To append visitor information to the URL that is being used to open the web view, call [appendVisitorInfoForUrl](../api-reference.md#appendtourl-appendvisitorinfoforurl):

```java
Identity.appendVisitorInfoForURL("https://example.com", new AdobeCallback<String>() {
@Override
public void call(String urlWithAdobeVisitorInfo) {
//handle the new URL here
//For example, open the URL on the device browser
//
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(urlWithAdobeVisitorInfo));
startActivity(i);
}
});
```

Alternately, starting in SDK version 1.4.0 (Identity version 1.1.0), you can call [getUrlVariables](../api-reference.md#geturlvariables) and build your own URL:

```java
Identity.getUrlVariables(new AdobeCallback<String>() {
@Override
public void call(String stringWithAdobeVisitorInfo) {
//handle the URL query parameter string here
//For example, open the URL on the device browser
//
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://example.com?" + urlWithAdobeVisitorInfo));
startActivity(i);
}
});
```

<Variant platform="ios" task="implement" repeat="10"/>

To append visitor information to the URL that is being used to open the web view, call [appendToUrl](../api-reference.md#appendtourl-appendvisitorinfoforurl):

#### Swift

```swift
let url = URL(string: "https://example.com")
Identity.appendTo(url: url) { appendedUrl, error in
if error != nil {
// handle error here
} else {
// handle appended url here
}
}
```

#### Objective-C

```objectivec
NSURL *sampleUrl = [NSURL URLWithString:@"https://example.com"];
[AEPMobileIdentity appendToUrl:sampleUrl completion:^(NSURL * _Nullable appendedUrl, NSError *error) {
if (error != nil) {
// Handle error here
} else {
// Handle appended url here
}
}];
```
Alternately, you can call [getUrlVariables](../api-reference.md#geturlvariables) and build your own URL:
#### Swift
```swift
Identity.getUrlVariables { urlVariables, error in
if error != nil {
// handle error here
} else {
if let url = URL(string: "https://example.com?\(urlVariables ?? "")") {
DispatchQueue.main.async {
UIApplication.shared.open(url)
}
}
}
}
```

#### Objective-C

```objectivec
[AEPMobileIdentity getUrlVariables:^(NSString * _Nullable urlVariables, NSError *error) {
NSString *sampleURLString = @"https://example.com";
if (error != nil) {
// Handle variables being nil
} else {
NSString *stringWithData = [NSString stringWithFormat:@"%@?%@", sampleURLString, urlVariables];
NSURL *appendedUrl = [NSURL URLWithString:stringWithData];
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] openURL:appendedUrl options:@{} completionHandler:nil];
});
}
}];
```
<!--- <Variant platform="react-native" task="implement" repeat="5"/>
#### JavaScript
To append visitor information to the URL that is being used to open the web view, call [appendVisitorInfoForUrl](../api-reference.md#appendtourl-appendvisitorinfoforurl):
```jsx
ACPIdentity.appendVisitorInfoForURL("www.example.com").then(urlWithVistorData => console.log("Url with Visitor Data = " + urlWithVisitorData));
```

Alternately, starting with SDK version 1.0.5, you can call [getUrlVariables](../api-reference.md#geturlvariables) and build your own URL:

```jsx
ACPIdentity.getUrlVariables().then(urlVariables => console.log("query params = " + urlVariables));
```

<Variant platform="flutter" task="implement" repeat="5"/>

#### Dart

To append visitor information to the URL that is being used to open the web view, call [appendVisitorInfoForUrl](../api-reference.md#appendtourl-appendvisitorinfoforurl):

```dart
String result = "";
try {
result = await FlutterACPIdentity.appendToUrl("www.example.com");
} on PlatformException {
log("Failed to append URL");
}
```

Alternately, starting with SDK version 1.0.0-beta.1, you can call [getUrlVariables](../api-reference.md#geturlvariables) and build your own URL:

```dart
String result = "";
try {
result = await FlutterACPIdentity.urlVariables;
} on PlatformException {
log("Failed to get url variables");
}
``` --->
145 changes: 0 additions & 145 deletions src/pages/home/base/mobile-core/identity/tabs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,148 +132,3 @@ When using React Native, registering Identity with Mobile Core should be done in
<Variant platform="flutter" task="register" repeat="1"/>
When using Flutter, registering Identity with Mobile Core should be done in native code, which is shown under the Android and iOS tabs. --->

<Variant platform="android" task="implement" repeat="5"/>

#### Java

To append visitor information to the URL that is being used to open the web view, call [appendVisitorInfoForUrl](#appendtourl-appendvisitorinfoforurl):

```java
Identity.appendVisitorInfoForURL("https://example.com", new AdobeCallback<String>() {
@Override
public void call(String urlWithAdobeVisitorInfo) {
//handle the new URL here
//For example, open the URL on the device browser
//
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(urlWithAdobeVisitorInfo));
startActivity(i);
}
});
```

Alternately, starting in SDK version 1.4.0 (Identity version 1.1.0), you can call [getUrlVariables](#geturlvariables) and build your own URL:

```java
Identity.getUrlVariables(new AdobeCallback<String>() {
@Override
public void call(String stringWithAdobeVisitorInfo) {
//handle the URL query parameter string here
//For example, open the URL on the device browser
//
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://example.com?" + urlWithAdobeVisitorInfo));
startActivity(i);
}
});
```

<Variant platform="ios" task="implement" repeat="10"/>

To append visitor information to the URL that is being used to open the web view, call [appendToUrl](./api-reference.md#appendtourl-appendvisitorinfoforurl):

#### Swift

```swift
let url = URL(string: "https://example.com")
Identity.appendTo(url: url) { appendedUrl, error in
if error != nil {
// handle error here
} else {
// handle appended url here
}
}
```

#### Objective-C

```objectivec
NSURL *sampleUrl = [NSURL URLWithString:@"https://example.com"];
[AEPMobileIdentity appendToUrl:sampleUrl completion:^(NSURL * _Nullable appendedUrl, NSError *error) {
if (error != nil) {
// Handle error here
} else {
// Handle appended url here
}
}];
```
Alternately, you can call [getUrlVariables](api-reference.md#geturlvariables) and build your own URL:
#### Swift
```swift
Identity.getUrlVariables { urlVariables, error in
if error != nil {
// handle error here
} else {
if let url = URL(string: "https://example.com?\(urlVariables ?? "")") {
DispatchQueue.main.async {
UIApplication.shared.open(url)
}
}
}
}
```

#### Objective-C

```objectivec
[AEPMobileIdentity getUrlVariables:^(NSString * _Nullable urlVariables, NSError *error) {
NSString *sampleURLString = @"https://example.com";
if (error != nil) {
// Handle variables being nil
} else {
NSString *stringWithData = [NSString stringWithFormat:@"%@?%@", sampleURLString, urlVariables];
NSURL *appendedUrl = [NSURL URLWithString:stringWithData];
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] openURL:appendedUrl options:@{} completionHandler:nil];
});
}
}];
```
<!--- <Variant platform="react-native" task="implement" repeat="5"/>
#### JavaScript
To append visitor information to the URL that is being used to open the web view, call [appendVisitorInfoForUrl](api-reference.md#appendtourl-appendvisitorinfoforurl):
```jsx
ACPIdentity.appendVisitorInfoForURL("www.example.com").then(urlWithVistorData => console.log("Url with Visitor Data = " + urlWithVisitorData));
```

Alternately, starting with SDK version 1.0.5, you can call [getUrlVariables](api-reference.md#geturlvariables) and build your own URL:

```jsx
ACPIdentity.getUrlVariables().then(urlVariables => console.log("query params = " + urlVariables));
```

<Variant platform="flutter" task="implement" repeat="5"/>

#### Dart

To append visitor information to the URL that is being used to open the web view, call [appendVisitorInfoForUrl](api-reference.md#appendtourl-appendvisitorinfoforurl):

```dart
String result = "";
try {
result = await FlutterACPIdentity.appendToUrl("www.example.com");
} on PlatformException {
log("Failed to append URL");
}
```

Alternately, starting with SDK version 1.0.0-beta.1, you can call [getUrlVariables](api-reference.md#geturlvariables) and build your own URL:

```dart
String result = "";
try {
result = await FlutterACPIdentity.urlVariables;
} on PlatformException {
log("Failed to get url variables");
}
``` --->
Loading

0 comments on commit b056f8c

Please sign in to comment.