Skip to content

Commit 34409db

Browse files
committed
wip
1 parent 80450a3 commit 34409db

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

src/connections/auto-instrumentation/web-setup.md

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ Choose one of the following installation methods based on your setup:
3131

3232
### Option A: Snippet Users (HTML)
3333

34-
For websites using the Segment snippet, add the SignalsPlugin using a CDN:
34+
For websites using the Segment snippet, please REPLACE the regular Segment snippet with the following code, which includes the Signals SDK:
35+
36+
> warning ""
37+
> If you are currently using Segment, replace the existing Segment snippet that loads analytics.js with the modified code below. You should not have two segment snippets that call analytics.load() in your html.
3538
3639
```html
3740
<head>
3841
<title>My Website</title>
39-
40-
<!-- Load Segment (find and replace '<YOUR_WRITE_KEY>') -->
41-
<script>
42+
<!-- Replace <YOUR_WRITE_KEY> in 'data-segment-write-key' -->
43+
<script data-segment-write-key="<YOUR_WRITE_KEY>">
4244
!(function () {
4345
var i = "analytics",
4446
analytics = (window[i] = window[i] || []);
@@ -121,21 +123,24 @@ For websites using the Segment snippet, add the SignalsPlugin using a CDN:
121123
r.parentNode.insertBefore(t, r);
122124
analytics._loadOptions = n;
123125
};
124-
// Replace with your Segment write key.
125-
analytics._writeKey = "<YOUR_WRITE_KEY>";
126+
127+
analytics._writeKey = script.getAttribute("data-segment-write-key");
126128
analytics.SNIPPET_VERSION = "5.2.0";
127-
analytics.page();
129+
130+
// Load analytics + signals
131+
var signalsScript = document.createElement("script");
132+
signalsScript.src =
133+
"https://cdn.jsdelivr.net/npm/@segment/analytics-signals@latest/dist/umd/analytics-signals.umd.js";
134+
signalsScript.async = true;
135+
signalsScript.onload = function () {
136+
var signalsPlugin = new SignalsPlugin();
137+
analytics.register(signalsPlugin);
138+
analytics.load(analytics._writeKey);
139+
};
140+
document.head.appendChild(signalsScript);
128141
}
129142
})();
130143
</script>
131-
132-
<!-- Register SignalsPlugin -->
133-
<script src="https://cdn.jsdelivr.net/npm/@segment/analytics-signals@latest/dist/umd/analytics-signals.umd.js"></script>
134-
<script>
135-
var signalsPlugin = new SignalsPlugin()
136-
analytics.register);
137-
analytics.load(analytics._writeKey);
138-
</script>
139144
</head>
140145
```
141146

@@ -183,23 +188,31 @@ After integrating the SDK and running your app, verify that Segment is collectin
183188

184189
1. In your Segment workspace, return to **Connections > Sources**, then select the source you created for Auto-Instrumentation.
185190
2. In the source overview, look for the **Event Builder** tab. If the tab doesn’t appear:
186-
- Make sure you've installed the SDK correctly.
187-
- Reach out to your Segment CSM to confirm that your workspace has the necessary feature flags enabled.
191+
192+
- Make sure you've installed the SDK correctly.
193+
- Reach out to your Segment CSM to confirm that your workspace has the necessary feature flags enabled.
188194
![The Event Builder tab shown in the navigation bar between Debugger and Schema in a Segment Source](images/event_builder_tab.png)
189-
3. Open the **Event Builder** and follow the on-screen instructions to start signal detection.
190-
- To collect signals in the UI, visit your site in a browser using the query string:`?segment_signals_debug=true`
195+
196+
3. Open the **Event Builder** and follow the on-screen instructions to start signal detection.
197+
198+
- To collect signals in the UI, visit your site in a browser using the query string:`?segment_signals_debug=true`
199+
191200
4. Interact with your app to trigger signals: click buttons, navigate pages, submit forms, and so on. Segment collects and displays these as signals in real time.
192201
5. From the signals list, click **Configure event** to define a new event based on one or more signals. After configuring the event, click **Publish event rules**.
193202

194-
195203
### Debugging
204+
196205
#### Enable debug mode
206+
197207
Values sent to the signals API are redacted by default.
198-
This adds a local storage key. To disable redaction, add a magic query string:
208+
This adds a local storage key. To disable redaction, add a magic query string:
209+
199210
```
200211
https://my-website.com?segment_signals_debug=true
201212
```
202-
You can *turn off debugging* by doing:
213+
214+
You can _turn off debugging_ by doing:
215+
203216
```
204217
https://my-website.com?segment_signals_debug=false
205218
```
@@ -305,4 +318,4 @@ Network signals emit when an HTTP Request is made, or an HTTP Response is receiv
305318

306319
## Next steps
307320

308-
This guide walked you through initial Signals SDK/Auto-Instrumentation setup. Next, read the [Auto-Instrumentation Signals Implementation Guide](/docs/connections/auto-instrumentation/configuration/), which dives deeper into Signals and offers example rules.
321+
This guide walked you through initial Signals SDK/Auto-Instrumentation setup. Next, read the [Auto-Instrumentation Signals Implementation Guide](/docs/connections/auto-instrumentation/configuration/), which dives deeper into Signals and offers example rules.

0 commit comments

Comments
 (0)