Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

The Guides and Surveys Android SDK requires:

* Android API Level 24 (Android 7.0) or higher
* Kotlin 1.8.22 or newer
* [Amplitude Android-Kotlin SDK](/docs/sdks/analytics/android/android-kotlin-sdk) 1.0 or higher.
* Android API Level 24 (Android 7.0)+
* Kotlin 1.8.22+
* [Amplitude Android-Kotlin SDK](/docs/sdks/analytics/android/android-kotlin-sdk) 1.0+

## Install and initialize the SDK

Guides and Surveys supports different installation options to work best with your existing Amplitude implementation, if you have one.

### Using Kotlin 1.8.22+
### Using Amplitude Android-Kotlin 1.0+

Add the following dependencies to your application's `build.gradle.kts` file:

Expand Down Expand Up @@ -79,6 +79,83 @@
After you call `amplitude.add`, you are technically done installing. While screen tracking and element targeting are optional, Amplitude recommends that you [set up URL handling for preview mode](/docs/guides-and-surveys/guides-and-surveys-android-sdk#simulate-guides-and-surveys-for-preview).
{{/partial:admonition}}

### Not using Amplitude Android-Kotlin 1.0+
In this case, installation is very similar to above; however, you need to manually call `.boot`.

Check warning on line 83 in content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Semicolon] Try to simplify this sentence. Raw Output: {"message": "[Microsoft.Semicolon] Try to simplify this sentence.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md", "range": {"start": {"line": 83, "column": 52}}}, "severity": "INFO"}

Check warning on line 83 in content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Adverbs] Remove 'very' if it's not important to the meaning of the statement. Raw Output: {"message": "[Microsoft.Adverbs] Remove 'very' if it's not important to the meaning of the statement.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md", "range": {"start": {"line": 83, "column": 31}}}, "severity": "WARNING"}

Add the following dependencies to your application's `build.gradle.kts` file:

```kotlin
dependencies {
// Amplitude Engagement SDK
implementation("com.amplitude:amplitude-engagement-android:1.0+")

// Amplitude Analytics SDK (required dependency)
implementation("com.amplitude:analytics-android:1.+")
}
```

#### Initialize the SDK

```kotlin
import com.amplitude.android.engagement.AmplitudeEngagement
import com.amplitude.android.engagement.AmplitudeInitOptions

// Initialize the SDK
val amplitudeEngagement = AmplitudeEngagement(
context = applicationContext,
apiKey = "YOUR_API_KEY",
options = AmplitudeInitOptions()
)

// Add the plugin to your Amplitude instance
val amplitude = Amplitude(applicationContext)
amplitude.add(amplitudeEngagement.getPlugin())
```

#### Configuration options

| Parameter | Type | Description |
| ------------------------ | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `apiKey` | `string` | Required. API key of the Amplitude project you want to use. |
| `initOptions.serverZone` | `EU` or `US` | Optional. Sets the Amplitude server zone. Set this to EU for Amplitude projects created in EU data center. Default: `US` |
| `initOptions.logLevel` | `LogLevel.None` or `LogLevel.Error` or `LogLevel.Warn` or `LogLevel.Verbose` or `LogLevel.Debug`. | Optional. Sets the log level. Default: `LogLevel.Warn` |
| `initOptions.locale` | `string` | Optional. Sets the locale for [localization](/docs/guides-and-surveys/sdk#localization). Default: `undefined`. Not setting a language means the default language is used. |

Check warning on line 122 in content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'is used' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'is used' looks like passive voice.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md", "range": {"start": {"line": 122, "column": 291}}}, "severity": "INFO"}

{{partial:admonition type="warning" heading="Use the same API key for Guides & Surveys and Analytics"}}
To avoid analytics mismatches and ensure accurate data collection, use the same API key for both Guides & Surveys and your Analytics SDK. Both should reference the same Amplitude project. Using different API keys can cause:

- The SDK to fetch guides and surveys from the wrong project
- Analytics data to appear in different projects
- Insights and survey responses are incomplete or mismatched

Make sure the API key you provide to Guides & Surveys matches the API key used to initialize your Amplitude Analytics SDK.
{{/partial:admonition}}

#### Boot the SDK

```kotlin
// Basic boot with user ID
amplitudeEngagement.boot("USER_ID")

// Advanced boot with options

let bootOptions = AmplitudeBootOptions(
userId: "USER_ID",
deviceId: "DEVICE_ID",
userProperties: mapOf("key" to "value")
integrations = arrayOf({ event: BaseEvent ->
// Custom event handler
// Dummy example here:
println("event: ${event.eventType} properties: ${event.eventProperties}")
})
)
amplitudeEngagement.boot(options: bootOptions)
```

{{partial:admonition type="note" heading=""}}
After you call `amplitude.boot`, you are technically done installing. While screen tracking and element targeting are optional, Amplitude recommends that you [set up URL handling for preview mode](/docs/guides-and-surveys/guides-and-surveys-android-sdk#simulate-guides-and-surveys-for-preview).
{{/partial:admonition}}

## Add your application to project settings

After installing the SDK, add your Android application to your Amplitude project settings so it appears as a platform option when you create guides and surveys.
Expand All @@ -101,16 +178,21 @@
Your Android package name is defined in your `AndroidManifest.xml` file or in your app-level `build.gradle` file as the `applicationId`.
{{/partial:admonition}}

### Enable screen tracking (optional)
## Screen tracking and element targeting
### Enable screen tracking

Required for screen targeting and the Time on Screen trigger.
Required for screen-based targeting and the Time on Screen trigger. The screen string (eg "HomeScreen" in the example below) is compared with the string provided in the guide or survey page targeting section.

Check warning on line 184 in content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'is compared' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'is compared' looks like passive voice.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md", "range": {"start": {"line": 184, "column": 126}}}, "severity": "INFO"}

Check failure on line 184 in content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Foreign] Use 'for example' instead of 'eg '. Raw Output: {"message": "[Microsoft.Foreign] Use 'for example' instead of 'eg '.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md", "range": {"start": {"line": 184, "column": 88}}}, "severity": "ERROR"}

Check failure on line 184 in content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'eg'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'eg'?", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md", "range": {"start": {"line": 184, "column": 88}}}, "severity": "ERROR"}

```kotlin
// Track screen views to trigger guides based on screens
amplitudeEngagement.screen("HomeScreen")
```

### Enable element targeting (optional)
{{partial:admonition type="warning" heading=""}}
`Screen Viewed` events from the Amplitude Android-Kotlin SDK's [Autocapture feature](/docs/sdks/analytics/android/android-kotlin-sdk#autocapture) are auto-forwarded to the Engagement SDK.

Check failure on line 192 in content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Auto] In general, don't hyphenate 'auto-forwarded'. Raw Output: {"message": "[Microsoft.Auto] In general, don't hyphenate 'auto-forwarded'.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-android-sdk.md", "range": {"start": {"line": 192, "column": 151}}}, "severity": "ERROR"}
{{/partial:admonition}}

### Enable element targeting

Pin and tooltip guides require the ability for the SDK to target specific elements on screen.

Expand Down
114 changes: 102 additions & 12 deletions content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,30 @@

Guides and Surveys supports different installation options to work best with your existing Amplitude implementation, if you have one.

### Using Amplitude Swift 5.9+
### Using Amplitude iOS Swift 1.13.0+

Check warning on line 27 in content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Headings] 'Using Amplitude iOS Swift 1.13.0+' should use sentence-style capitalization. Raw Output: {"message": "[Microsoft.Headings] 'Using Amplitude iOS Swift 1.13.0+' should use sentence-style capitalization.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md", "range": {"start": {"line": 27, "column": 5}}}, "severity": "INFO"}

First, install the Guides and Surveys iOS SDK with Swift Package Manager or CocoaPods.

{{partial:tabs tabs="Swift Package Manager, CocoaPods"}}
{{partial:tab name="Swift Package Manager"}}
1. In Xcode, click *File > Add Packages...*
2. Enter the repository URL `https://github.com/amplitude/Amplitude-Engagement-Swift`
3. Select the `Amplitude-Engagement-Swift` package, version `1.0.5`.
3. Select the `Amplitude-Engagement-Swift` package, version `1.6.0`.
4. Click **Add Package**.
{{/partial:tab}}
{{partial:tab name="CocoaPods"}}
Add the following line to your Podfile, then run `pod install`.

```T
pod 'AmplitudeEngagementSwift', '~> 1.0.5'
pod 'AmplitudeEngagementSwift', '~> 1.6.0'
```
{{/partial:tab}}
{{/partial:tabs}}

{{partial:admonition type="note" heading=""}}
We don't update our docs on each release. You can check for the latest version here: https://github.com/amplitude/Amplitude-Engagement-Swift

Check warning on line 48 in content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.We] Try to avoid using first-person plural like 'our'. Raw Output: {"message": "[Microsoft.We] Try to avoid using first-person plural like 'our'.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md", "range": {"start": {"line": 48, "column": 17}}}, "severity": "WARNING"}

Check warning on line 48 in content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.We] Try to avoid using first-person plural like 'We'. Raw Output: {"message": "[Microsoft.We] Try to avoid using first-person plural like 'We'.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md", "range": {"start": {"line": 48, "column": 1}}}, "severity": "WARNING"}
{{/partial:admonition}}

#### Initialize the SDK

Next, make sure to initialize the SDK.
Expand Down Expand Up @@ -107,14 +111,98 @@
Your iOS bundle identifier is defined in your Xcode project settings under **General** > **Identity** > **Bundle Identifier**.
{{/partial:admonition}}

### Enable screen tracking (optional)
### Not using Amplitude Swift 1.13.0+
In this case, installation is very similar to above; however, you need to manually call `.boot`.

Check warning on line 115 in content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Semicolon] Try to simplify this sentence. Raw Output: {"message": "[Microsoft.Semicolon] Try to simplify this sentence.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md", "range": {"start": {"line": 115, "column": 52}}}, "severity": "INFO"}

Check warning on line 115 in content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Adverbs] Remove 'very' if it's not important to the meaning of the statement. Raw Output: {"message": "[Microsoft.Adverbs] Remove 'very' if it's not important to the meaning of the statement.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md", "range": {"start": {"line": 115, "column": 31}}}, "severity": "WARNING"}

First, install the Guides and Surveys iOS SDK with Swift Package Manager or CocoaPods.

{{partial:tabs tabs="Swift Package Manager, CocoaPods"}}
{{partial:tab name="Swift Package Manager"}}
1. In Xcode, click *File > Add Packages...*
2. Enter the repository URL `https://github.com/amplitude/Amplitude-Engagement-Swift`
3. Select the `Amplitude-Engagement-Swift` package, version `1.6.0`.
4. Click **Add Package**.
{{/partial:tab}}
{{partial:tab name="CocoaPods"}}
Add the following line to your Podfile, then run `pod install`.

```T
pod 'AmplitudeEngagementSwift', '~> 1.6.0'
```
{{/partial:tab}}
{{/partial:tabs}}

{{partial:admonition type="note" heading=""}}
We don't update our docs on each release. You can check for the latest version here: https://github.com/amplitude/Amplitude-Engagement-Swift
{{/partial:admonition}}

#### Initialize the SDK

```swift
import AmplitudeEngagementSwift


let amplitudeEngagement = AmplitudeEngagement("YOUR_API_KEY")


let configuration = Configuration(
apiKey: API_KEY
)
let amplitude = Amplitude(configuration: configuration)
amplitude.add(plugin: amplitudeEngagement.getPlugin())
```

#### Configuration options

| Parameter | Type | Description |
| ------------------------ | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `apiKey` | `string` | Required. API key of the Amplitude project you want to use. |
| `initOptions.serverZone` | `EU` or `US` | Optional. Sets the Amplitude server zone. Set this to EU for Amplitude projects created in EU data center. Default: `US` |
| `initOptions.logLevel` | `LogLevel.None` or `LogLevel.Error` or `LogLevel.Warn` or `LogLevel.Verbose` or `LogLevel.Debug`. | Optional. Sets the log level. Default: `LogLevel.Warn` |
| `initOptions.locale` | `string` | Optional. Sets the locale for [localization](/docs/guides-and-surveys/sdk#localization). Default: `undefined`. Not setting a language means the default language is used. |

#### Boot the SDK

```swift
// Basic boot with user ID
amplitudeEngagement.boot("USER_ID")

// Advanced boot with options

let bootOptions = AmplitudeBootOptions(
user_id: "USER_ID",
device_id: "DEVICE_ID",
user_properties: ["key": "value"]
integrations: [
{ event, eventProperties in
// Custom event handler
}
]
)
amplitudeEngagement.boot(options: bootOptions)
```

{{partial:admonition type="note" heading=""}}
After you call `amplitudeEngagement.boot`, you are technically done installing. While screen tracking and element targeting are optional, we highly recommend [setting up URL handling for preview mode](/docs/guides-and-surveys/guides-and-surveys-ios-sdk#simulate-guides-and-surveys-for-preview).
{{/partial:admonition}}

## Screen tracking and element targeting
Screen tracking and element targeting are technically optional, but can be very helpful for making your guides and surveys feel more targeted.

### Enable screen tracking

Required for screen-based targeting and the Time on Screen trigger. The screen string (eg "HomeScreen" in the example below) is compared with the string provided in the guide or survey page targeting section.

Check failure on line 194 in content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Foreign] Use 'for example' instead of 'eg '. Raw Output: {"message": "[Microsoft.Foreign] Use 'for example' instead of 'eg '.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md", "range": {"start": {"line": 194, "column": 88}}}, "severity": "ERROR"}

Check failure on line 194 in content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'eg'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'eg'?", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md", "range": {"start": {"line": 194, "column": 88}}}, "severity": "ERROR"}

```swift
// Track screen views to trigger guides based on screens
amplitudeEngagement.screen("HomeScreen")
```

### Enable element targeting (optional)
{{partial:admonition type="warning" heading=""}}
`Screen Viewed` events from the Amplitude iOS Swift SDK's [Autocapture feature](/docs/sdks/analytics/ios/ios-swift-sdk#autocapture) are auto-forwarded to the Engagement SDK.

Check failure on line 202 in content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Auto] In general, don't hyphenate 'auto-forwarded'. Raw Output: {"message": "[Microsoft.Auto] In general, don't hyphenate 'auto-forwarded'.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-ios-sdk.md", "range": {"start": {"line": 202, "column": 137}}}, "severity": "ERROR"}
{{/partial:admonition}}

### Enable element targeting

Pin and tooltip guides require the ability for the SDK to target specific elements on screen. To enable this in your app, give the element a unique identifier.

Expand All @@ -132,7 +220,9 @@
myView.accessibilityIdentifier = "MyView"
```

## Manage themes
## Other SDK Methods

### Manage themes

Configure the visual theme mode if your app supports light and dark modes.

Expand All @@ -142,7 +232,7 @@
amplitudeEngagement.setThemeMode(ThemeMode.DARK) // Options: AUTO, LIGHT, DARK
```

## Router configuration
### Router configuration

Configure how Guides and Surveys handles screen navigation.

Expand All @@ -161,7 +251,7 @@
After you configure the router with `setRouter()`, update the link behavior setting in the Guides and Surveys interface. For any link actions in your guides or surveys, change the behavior to **Use router**. This ensures that the guide or survey uses the custom router function instead of the default browser navigation.
{{/partial:admonition}}

## Reset
### Reset

Reset a guide or survey to a specific step.

Expand All @@ -175,15 +265,15 @@
| `stepIndex` | `number` | Required. The zero-based index of the step to reset to. Defaults to the initial step. |


## List
### List

Retrieve a list of all live guides and surveys along with their status.

```swift
val guidesAndSurveys = amplitudeEngagement.list()
```

## Show
### Show

Display a specific guide or survey. Ignores any targeting rules and limits except for screen targeting.

Expand All @@ -196,7 +286,7 @@
| `key` | `string` | Required. The guide or survey's key. |


## Forward event
### Forward event

If you don't use the plugin, but want to trigger Guides using events.

Expand All @@ -207,7 +297,7 @@
])
```

## Close all
### Close all

Close all active guides and surveys.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,35 @@
At this point, you are technically done installing. While optional, Amplitude recommends that you [set up URL handling for preview mode](/docs/guides-and-surveys/guides-and-surveys-rn-sdk#configure-linking).
{{/partial:admonition}}

## Element targeting

Pin and tooltip guides require the ability for the SDK to target specific views on screen. The Engagement SDK uses the "testID" property on an element in the React Native DOM.

In the example component below, "welcome-banner" is the element targeting string that should be used in the Guides and Surveys dashboard.

Check warning on line 100 in content/collections/guides_and_surveys/en/guides-and-surveys-rn-sdk.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Microsoft.Passive] 'be used' looks like passive voice. Raw Output: {"message": "[Microsoft.Passive] 'be used' looks like passive voice.", "location": {"path": "content/collections/guides_and_surveys/en/guides-and-surveys-rn-sdk.md", "range": {"start": {"line": 100, "column": 94}}}, "severity": "INFO"}

```js
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

/**
* A simple component with a testID that can be targeted
* by the Amplitude Guides & Surveys SDK.
*/
export default function WelcomeBanner() {
return (
<View
testID="welcome-banner" // Element targeting via testID
style={styles.banner}
>
<Text style={styles.bannerText}>
Welcome to the App!
</Text>
</View>
);
}
```


## Configure linking

If your app doesn't have deep linking enabled, follow the [React Native instructions](https://reactnative.dev/docs/linking#enabling-deep-links) to add support for deep linking. Previewing Guides and Surveys on a device requires this support.
Expand Down
Loading