Skip to content

Commit a699c69

Browse files
authored
Merge pull request #1057 from amplitude/promptless/update-unified-sdk-engagement-support
docs: Update unified SDK documentation for Guides and Surveys support
2 parents bf5b89d + 19c45d8 commit a699c69

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

content/collections/browser_sdk/en/browser-unified-sdk.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,19 @@ package_name: '@amplitude/unified'
1818
platform: Browser
1919
full_details: true
2020
---
21-
The Unified SDK provides a single entry point for all Amplitude features, including Analytics, Experiment, and Session Replay. It simplifies the integration process by handling the initialization and configuration of all components.
21+
The Unified SDK provides a single entry point for all Amplitude features, including Analytics, Experiment, Session Replay, and Guides and Surveys. It simplifies the integration process by handling the initialization and configuration of all components.
2222

2323
{{partial:admonition type="beta" heading="Beta Release"}}
2424
The Browser Unified SDK is currently in beta. There may be breaking changes before the stable release. Amplitude recommends testing thoroughly in a development environment before you deploy to production.
2525
{{/partial:admonition}}
2626

2727
{{partial:admonition type="info" heading="Individual Product Installation"}}
28-
The Unified SDK installs Analytics, Experiment, and Session Replay. If you're concerned about bundle size and only need specific products, you can install them individually:
28+
The Unified SDK installs Analytics, Experiment, Session Replay, and Guides and Surveys. If you're concerned about bundle size and only need specific products, you can install them individually:
2929

3030
- [Analytics](/docs/sdks/analytics/browser/browser-sdk-2) - For tracking user events and behavior
3131
- [Experiment](/docs/sdks/experiment-sdks/experiment-javascript) - For running A/B tests and feature flags
3232
- [Session Replay](/docs/session-replay/session-replay-standalone-sdk) - For capturing and replaying user sessions
33-
34-
The Unified SDK doesn't support Guides and Surveys. If you need Guides and Surveys functionality, use the [Guides and Surveys SDK](/docs/guides-and-surveys/sdk) directly.
33+
- [Guides and Surveys](/docs/guides-and-surveys/sdk) - For in-product messaging and surveys
3534
{{/partial:admonition}}
3635

3736
## Install the SDK
@@ -70,6 +69,7 @@ For detailed information about each product's features and APIs, refer to their
7069
- [Analytics Browser SDK](/docs/sdks/analytics/browser/browser-sdk-2)
7170
- [Experiment JavaScript SDK](/docs/sdks/experiment-sdks/experiment-javascript)
7271
- [Session Replay Standalone SDK](/docs/session-replay/session-replay-standalone-sdk)
72+
- [Guides and Surveys Web SDK](/docs/guides-and-surveys/sdk)
7373
{{/partial:admonition}}
7474

7575
```typescript
@@ -119,6 +119,11 @@ initAll('YOUR_API_KEY', {
119119
// Experiment options
120120
experiment: {
121121
// Experiment configuration options
122+
},
123+
124+
// Guides and Surveys options
125+
engagement: {
126+
// Guides and Surveys configuration options
122127
}
123128
});
124129
```
@@ -144,3 +149,7 @@ Sample Rate controls the rate at which Amplitude captures session replays. For e
144149
### Experiment options
145150

146151
All options from `@amplitude/plugin-experiment-browser` are supported. See the [Experiment documentation](/docs/sdks/experiment-sdks/experiment-javascript#configuration) for details.
152+
153+
### Guides and Surveys options
154+
155+
The Unified Browser SDK supports all [Guides and Surveys options](/docs/guides-and-surveys/sdk#initialize-the-sdk). The engagement plugin initializes automatically when you pass engagement options in the configuration.

content/collections/guides_and_surveys/en/sdk.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Amplitude's Guides and Surveys SDK enables you to deploy [Guides and Surveys](/d
1313

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

16-
### Amplitude Browser SDK
16+
### Amplitude Browser SDK 2
1717

1818
Install the Guides and Surveys SDK with a script, or as a package with npm or Yarn.
1919

@@ -47,15 +47,36 @@ amplitude.add(engagementPlugin());
4747
{{/partial:tab}}
4848
{{/partial:tabs}}
4949

50+
For additional configuration, supply `InitOptions` to the `plugin` function. Go to [Initialize the SDK](#initialize-the-sdk) below for the available options.
5051

51-
For additional configuration, supply `InitOptions` to the `plugin` function. See [Initialize the SDK](#initialize-the-sdk) below for the available options.
52+
{{partial:admonition type="note" heading=""}}
53+
After the installation steps are complete, by default all Guides and Surveys events are sent to your project.
54+
{{/partial:admonition}}
55+
56+
Behind the scenes, `amplitude.add(engagementPlugin())` takes care of both `init` and `boot`. However, this option can only be used with the [Amplitude Analytics Browser SDK 2](/docs/sdks/analytics/browser/browser-sdk-2).
57+
58+
You should only call `init` and `boot` if you (a) want to use a proxy; (b) want to customize the event handling via the `integrations` option. You can learn more about using a proxy [here](/docs/guides-and-surveys/proxy). You can find details about the `integrations` option [here](/docs/guides-and-surveys/sdk#other-amplitude-sdks-and-third-party-analytics-providers).
5259

60+
### Amplitude Unified SDK
5361

62+
If you're using the [Amplitude Unified SDK](/docs/sdks/analytics/browser/browser-unified-sdk), Guides and Surveys comes out of the box. Just provide the engagement options during initialization:
5463

64+
```ts
65+
import { initAll } from '@amplitude/unified';
66+
67+
initAll('YOUR_API_KEY', {
68+
// Other Amplitude SDK options...
69+
engagement: {
70+
// Guides and Surveys options go here...
71+
}
72+
});
73+
```
74+
75+
Enable Guides and Surveys in your Amplitude project settings before guides and surveys can display. Go to [Unified SDK documentation](/docs/sdks/analytics/browser/browser-unified-sdk#guides-and-surveys-options) for details.
5576

5677
### Other Amplitude SDK's and third-party analytics providers
5778

58-
If you don't use the Amplitude Analytics [Browser SDK 2](/docs/sdks/analytics/browser/browser-sdk-2), you can still use Guides and Surveys but you need to configure the SDK to work with your other Amplitude Analytics SDK or third-party analytics provider. First, add the SDK to your project using the script tag, or through npm or Yarn as outlined above.
79+
If you don't use the [Amplitude Analytics Browser SDK 2](/docs/sdks/analytics/browser/browser-sdk-2) or the [Amplitude Analytics Unified SDK](/docs/sdks/analytics/browser/browser-unified-sdk), you can still use Guides and Surveys but you need to configure the SDK to work with your other Amplitude Analytics SDK or third-party analytics provider. First, add the SDK to your project using the script tag, or through npm or Yarn as outlined above.
5980
But, instead of calling `amplitude.add(window.engagement.plugin())`, you need to call `init` and `boot`.
6081

6182
#### Initialize the SDK
@@ -99,6 +120,10 @@ engagement.init("YOUR_API_KEY", {
99120
});
100121
```
101122

123+
{{partial:admonition type="note" heading=""}}
124+
When using a proxy, call `window.engagement.boot` to fully install Guides and Surveys, even if you are using the Browser SDK v2. Make sure to set up event handling through the `integrations` option.
125+
{{/partial:admonition}}
126+
102127
##### Example: Initialization with CSP nonce
103128

104129
For Content Security Policy (CSP) compliance, include a nonce value:
@@ -134,11 +159,11 @@ await window.engagement.boot({
134159
device_id: 'DEVICE_ID',
135160
user_properties: {},
136161
},
137-
// needed for insights and responses to populate
162+
// needed for insights and responses to populate
138163
integrations: [
139164
{
140165
track: (event) => {
141-
analytics.track(event.event_type, event.event_properties)
166+
amplitude.track(event.event_type, event.event_properties)
142167
}
143168
},
144169
],
@@ -148,7 +173,8 @@ await window.engagement.boot({
148173
To use *On event tracked* [triggers](/docs/guides-and-surveys/guides/setup-and-target#triggers), forward events from your third-party analytics provider to Guides and Surveys. The Guides and Surveys SDK doesn't send these events to the server.
149174

150175
```js
151-
analytics.on('track', (event, properties, options) => { // Example for Segment Analytics
176+
analytics.on('track', (event, properties, options) => {
177+
// Example for Segment Analytics
152178
window.engagement.forwardEvent({ event_type: event, event_properties: properties});
153179
});
154180
```

0 commit comments

Comments
 (0)