|
| 1 | +--- |
| 2 | +title: Analytics.js OneTrust Wrapper |
| 3 | +plan: consent-management |
| 4 | +--- |
| 5 | + |
| 6 | +Segment does not support *some* implementations of the Analytics.js OneTrust wrapper, as they might lead to noncompliance and data loss. This guide contains context about which configurations might cause data loss, steps you can take to remediate data loss, and configurations that minimize data loss. |
| 7 | + |
| 8 | +For questions about OneTrust Consent and Preference Management behavior, see the [OneTrust documentation](https://my.onetrust.com/s/topic/0TO3q000000kIWOGA2/universal-consent-preference-management?language=en_US){:target="_blank”}. |
| 9 | + |
| 10 | +For questions about the Analytics.js OneTrust wrapper, see the [@segment/analytics-consent-wrapper-onetrust](https://github.com/segmentio/analytics-next/tree/master/packages/consent/consent-wrapper-onetrust){:target="_blank”} repository. |
| 11 | + |
| 12 | +## OneTrust consent banner behavior |
| 13 | + |
| 14 | +The OneTrust consent banner has three key UI configurations that control how the banner and consent preferences behave: |
| 15 | + |
| 16 | +- **Banner display:** If the banner should be shown or not when a user lands on your webpage |
| 17 | +- **Banner closing:** If the consent banner should automatically close when the user takes an action on your webpage |
| 18 | +- **Consent model:** If the status is automatically set to `true` or `false` for all categories |
| 19 | + - **Opt-In:** The user, by default does not consent to all categories (except those that you deem to be mandatory). The user is required to select categories that they consent to share data with (or, opt-in to data collection) |
| 20 | + - **Opt-out:** The user, by default, does consent to all categories. The user can choose to select categories that they do not consent to share data with (or, opt-out of data collection) |
| 21 | + - **Custom:** You define the default for each consent category. The user can choose to select categories that they do not consent to share data with (opt-out of data collection) |
| 22 | + |
| 23 | +<div class="premonition info"> |
| 24 | + <div class="fa fa-info-circle"></div> |
| 25 | + <div class="content"> |
| 26 | + <p class="header">Segment's Analytics.js OneTrust wrapper assumes the following:</p> |
| 27 | + <p markdown=1> |
| 28 | + **Opt-In** and **Implied** statuses are treated in Segment's OneTrust wrapper as `Opt-In`. **Notice Only**, **Custom**, or **Opt-Out** statuses are treated in Segment's OneTrust wrapper as `Opt-Out`. |
| 29 | + </p> |
| 30 | + </div> |
| 31 | + </div> |
| 32 | + |
| 33 | +<!-- TODO (IG, 4/2024): the above callout would not render correctly in markdown - figure out why that happened--> |
| 34 | + |
| 35 | + |
| 36 | +You can set use the banner display and banner closing settings to either create a banner implementation that is **mandatory**, or must be interacted with before a user can access your site, or **optional**, where a banner is either always present as your end users navigate through your site, disappears after a user takes an action, like clicking or scrolling, or is never shown to your users. |
| 37 | + |
| 38 | +Some combinations of banner behaviors and consent models may lead to a [risk of data loss in your downstream destinations](#scenarios-where-you-might-experience-data-loss). |
| 39 | + |
| 40 | +### Risk evaluation |
| 41 | + |
| 42 | +Segment has evaluated a combination of banner behaviors, consent models, and load orders to be at either a [low](#low) risk or [medium](#medium) risk of data loss. |
| 43 | + |
| 44 | +#### Low |
| 45 | + |
| 46 | +Segment assess some behaviors to have a low risk of data loss and noncompliance because Twilio Segment analytics.js and third-party device mode libraries are loaded only after the user has provided their consent (for consent banners a user **must** interact with to use your site) or if Segment assumes that a user consents (if you set your cookie banner on your site to be optional and never displayed to a user). |
| 47 | + |
| 48 | +#### Medium |
| 49 | + |
| 50 | +Segment assess some banner behaviors, like those that always remain as a user navigates your site and those that disappear after a user action like clicking or scrolling, to be at a medium risk for data loss and noncompliance. |
| 51 | + |
| 52 | +- **Compliance Risk**: Once device mode libraries are loaded they cannot be unloaded when the user revokes consent to their mapped categories. *Note: Not unloading the library poses a risk **only** if the library is collecting data in addition to collecting Segment events.* |
| 53 | +- **Data loss Risk**: Once Segment loads, if the user consents to additional categories that map to device mode libraries, then these new libraries will not be loaded until the next time that Segment loads, like after a page reload. This may result in data loss. |
| 54 | + |
| 55 | +To minimize the risks of having a medium risk level: |
| 56 | + |
| 57 | +- Set up cookie banners that either must be interacted with in order to use your site, or are set to be optional and never displayed to a user, with the assumption that users rarely go back to update consent preferences |
| 58 | +- If using cookie banners that either always remain as a user navigates your site or disappear after a user action, like clicking or scrolling: |
| 59 | + - **Use fewer device mode libraries.** This way, all data flows through Twilio Segment and you can respect an end-user's consent preferences using Consent Management |
| 60 | + - **Regularly audit your device mode libraries.** Audit your device mode libraries to confirm they are not capturing data themselves |
| 61 | + - **Add logic to do a full page refresh when the user’s consent to categories associated with device mode libraries changes.** This will help unload the device mode libraries completely. |
| 62 | + |
| 63 | +> info " " |
| 64 | +> Refreshing a page when a user's consent changes could cause duplicate page events in your destinations. This can also cause a loss of form state for your users, if input form fields were present at the time of refresh. However, page refreshes due to changes in consent can also help load additional device mode libraries the user has consented to share data with, eliminating the risk of data loss in your downstream destinations. |
| 65 | +
|
| 66 | +## Segment library desired behavior |
| 67 | + |
| 68 | +| Banner behavior | Cookie banner | User interaction with webpage | Segment loads | Risk | Support Status | |
| 69 | +| --------------- | ------------ | ----------------------------- | ------------ | ---- | -------------- | |
| 70 | +| Mandatory | <img class="inline" src="/docs/images/supported.svg" /> Displayed on page load | <img class="inline" src="/docs/images/supported.svg" /> Required to access webpage | After use action | [Low](#low), until a user changes their preferences | <img class="inline" src="/docs/images/supported.svg" /> Supported | |
| 71 | +| A banner that always remains as a user navigates your site | <img class="inline" src="/docs/images/supported.svg" /> Displayed on page load | <img class="inline" src="/docs/images/unsupported.svg" /> Not required to access webpage | With page load | [Medium](#medium) | <img class="inline" src="/docs/images/unsupported.svg" /> Unsupported | |
| 72 | +| A banner that disappears after a user action, like clicking or scrolling | <img class="inline" src="/docs/images/supported.svg" /> Displayed on page load | <img class="inline" src="/docs/images/unsupported.svg" /> Not required to access webpage | With page load | [Medium](#medium) | <img class="inline" src="/docs/images/unsupported.svg" /> Unsupported | |
| 73 | +| A banner that is optional and never displayed to a user | <img class="inline" src="/docs/images/unsupported.svg" /> Not displayed on page load | <img class="inline" src="/docs/images/unsupported.svg" /> Not required to access webpage | With page load | [Low](#low), until a user changes their preferences | <img class="inline" src="/docs/images/supported.svg" /> Supported | |
| 74 | + |
| 75 | +## Scenarios where you might experience data loss |
| 76 | + |
| 77 | +You might experience data loss if a user navigates away from a landing page before providing their consent or doesn't interact with a consent banner on a website that uses an opt-in consent model. The following tables outline common scenarios that your users might encounter and information about the degree of data loss you can expect for each scenario. |
| 78 | + |
| 79 | +### First time users |
| 80 | + |
| 81 | +> info "" |
| 82 | +> Return users with no valid prior session are treated as first time users. |
| 83 | +
|
| 84 | +<table> |
| 85 | + <thead> |
| 86 | + <th> Consent model </th> |
| 87 | + <th> User action </th> |
| 88 | + <th> Expected behavior </th> |
| 89 | + <th> Data loss </th> |
| 90 | + </thead> |
| 91 | + <tbody> |
| 92 | + <tr> |
| 93 | + <td rowspan="3">Opt-In <i>(optional banner behavior)</i></td> |
| 94 | + <td>User provides consent preferences and closes banner (with or without the presence of strictly necessary destinations) </td> |
| 95 | + <td> 1. Website loads <br><br> 2. Website presents consent banner to a user <br><br> 3. Users provide consent preference and close banner <br><br> 4. Segment libraries load <br><br>5. Any events in the buffer for that session are sent to consented destinations (Segment and third-party destinations) <br><br> 6. All events after a user provides their consent will flow to consented destinations (Segment and third-party destinations)</td> |
| 96 | + <td>Data loss is possible if the user navigates away from the landing page before providing consent or if a user closes the banner. <br><br> No data loss if the user provides consent on the landing page </td> |
| 97 | + </tr> |
| 98 | + <tr> |
| 99 | + <td> User does not interact with the consent banner and continues to access the website </td> |
| 100 | + <td> 1. Website loads <br><br> 2. Website presents consent banner to a user <br><br> 3. User does not take a consent action and continues to access the website <br><br> 4. No Segment cookies are set <br><br>5. No events flow to Segment or third-party destinations</td> |
| 101 | + <td> Data loss. No data flows to strictly necessary or unmapped destinations </td> |
| 102 | + </tr> |
| 103 | + <tr> |
| 104 | + <td> User <b>rejects all</b> cookies and closes banner </td> |
| 105 | + <td>1. Website loads <br><br>2. Website presents consent banner to a user<br><br>3. User <b>rejects all</b> cookies and closes banner <br><br>4. If workspace has unmapped destinations or strictly necessary destinations, Segment libraries load<br><br> 5. Any events in the buffer for that session are sent to unmapped or strictly necessary destinations <br><br>6. All events after a user rejects consent flow to unmapped or strictly necessary destinations </td> |
| 106 | + <td>Data loss is possible if the user navigates away from the landing page before providing consent or if a user closes the banner. <br><br> No data loss if the user provides consent on the landing page </td> |
| 107 | + </tr> |
| 108 | + <tr> |
| 109 | + <td>Opt-In <i>(with mandatory consent banner)</i></td> |
| 110 | + <td>User provides consent preferences and closes banner</td> |
| 111 | + <td> 1. Website loads <br><br> 2. Website presents consent banner to a user, who cannot use your website until they interact with the banner <br><br>3. User provides consent preferences and closes banner <br><br> 4. Segment libraries load <br><br> 5. All events flow to consented destinations (Segment and third-party destinations)</td> |
| 112 | + <td> No data loss </td> |
| 113 | + </tr> |
| 114 | + <tr> |
| 115 | + <td rowspan="3">Opt-out</td> |
| 116 | + <td> User provides consent preference and closes banner </td> |
| 117 | + <td> 1. Website loads <br><br> 2. Segment libraries load <br><br> 3. Events flow to default consented and unmapped destinations (Segment and third party destinations) <br><br> 4. Website presents consent banner to a user <br><br> 5. User provides consent preferences and closes banner <br><br> 6. Events flow to unmapped destinations and destinations in categories your user consented to share data with. Events do not flow to mapped destinations in categories that your user did not consent to share data with </td> |
| 118 | + <td> No data loss <br><br> Device mode libraries that are passively collecting data and are mapped to categories a user does not consent to share data with might still be collecting data. <br><br><b>Segment is not able to block that data collection.</b></td> |
| 119 | + </tr> |
| 120 | + <tr> |
| 121 | + <td>User does not interact with the consent banner and continues to access the website</td> |
| 122 | + <td> 1. Website loads <br><br> 2. Segment libraries load <br><br> 3. Events flow to default consented and unmapped destinations (Segment and third-party destinations) <br><br> 4. Website presents consent banner to a user <br><br> 5. User does not interact with the consent banner and continues to access the website <br><br> 6. Events continue to flow to all connected destinations </td> |
| 123 | + <td> No data loss </td> |
| 124 | + </tr> |
| 125 | + <tr> |
| 126 | + <td> User provides consent preferences, <b>rejects all categories</b>, and closes the banner </td> |
| 127 | + <td> 1. Website loads <br><br> 2. Segment libraries load <br><br> 3. Events flow to default consented destinations (Segment and third-party destinations) <br><br> 4. Website presents consent banner to a user <br><br> 5. User provides consent preferences, <b>rejects all categories</b> and closes the banner. <br><br><br> If your workspace has <b>no unmapped or strictly necessary destinations</b>, all event data after a user provides their consent data is blocked. <br><br><br> If your workspace has <b>unmapped or strictly necessary destinations</b>, events continue to flow to unmapped destinations. </td> |
| 128 | + <td> No data loss <br><br> Device mode libraries that are passively collecting data and are mapped to categories a user does not consent to share data with might still be collecting data. <br><br><b>Segment is not able to block that data collection.</b></td> |
| 129 | + </tr> |
| 130 | + <tr> |
| 131 | + <td>Implied</td> |
| 132 | + <td>User does not interact with the consent banner and continues to access the website</td> |
| 133 | + <td> 1. Website loads <br><br> 2. Segment libraries load <br><br> 3. Events flow to default consented and unmapped destinations (Segment and third-party destinations) <br><br> 4. Website presents consent banner to a user <br><br> 5. User does not interact with the consent banner and continues to access the website <br><br> 6. Events continue to flow to all connected destinations </td> |
| 134 | + <td> No data loss </td> |
| 135 | + </tr> |
| 136 | + </tbody> |
| 137 | +</table> |
| 138 | + |
| 139 | + |
| 140 | +### Return users |
| 141 | + |
| 142 | +<table> |
| 143 | + <thead> |
| 144 | + <th> Consent model </th> |
| 145 | + <th> User action </th> |
| 146 | + <th> Expected behavior </th> |
| 147 | + <th> Data loss </th> |
| 148 | + </thead> |
| 149 | + <tbody> |
| 150 | + <tr> |
| 151 | + <td rowspan="2">Opt-In<i>(with mandatory or optional consent banner)</i></td> |
| 152 | + <td>1. Website loads <br><br> 2. Segment libraries load <br><br> 3. Events flow to default consented and unmapped destinations (Segment and third-party destinations) <br><br>4. User does not interact with the consent banner and continues to access the website</td> |
| 153 | + <td>No data loss</td> |
| 154 | + </tr> |
| 155 | + <tr> |
| 156 | + <td> User seeks, opens, and updates cookies on the banner, then closes the banner</td> |
| 157 | + <td> 1. Website loads <br><br> 2. Segment libraries load <br><br> 3. Events flow to default consented destinations (Segment and third-party destinations)<br><br>4. User seeks, opens, and updates cookies on the banner<br><br>5. User closes banner<br><br>6. Events flow to consented destinations, are block from flowing to mapped, non-consented destinations.<br>If a user rejects all categories and your Segment workspace has no unmapped destinations, <b>no data will flow to any destination</b><br>If a user rejects all categories and your Segment workspace has unmapped destinations, <b>data will flow to your unmapped destinations</b></td> |
| 158 | + <td> No data loss <br><br> Device mode libraries that are passively collecting data and are mapped to categories a user does not consent to share data with might still be collecting data. <br><br><b>Segment is not able to block that data collection.</b></td> |
| 159 | + </tr> |
| 160 | + <tr> |
| 161 | + <td rowspan="2">Opt-out<i>(with mandatory or optional consent banner)</i></td> |
| 162 | + <td>1. Website loads <br><br> 2. Segment libraries load <br><br> 3. Events flow to default consented and unmapped destinations (Segment and third-party destinations) <br><br>4. User does not interact with the consent banner and continues to access the website</td> |
| 163 | + <td>No data loss</td> |
| 164 | + </tr> |
| 165 | + <tr> |
| 166 | + <td> User seeks, opens, and updates cookies on the banner, then closes the banner</td> |
| 167 | + <td> 1. Website loads <br><br> 2. Segment libraries load <br><br> 3. Events flow to default consented destinations (Segment and third-party destinations)<br><br>4. User seeks, opens, and updates cookies on the banner<br><br>5. User closes banner<br><br>6. Events flow to consented destinations, are block from flowing to mapped, non-consented destinations.<br>If a user rejects all categories and your Segment workspace has no unmapped destinations, <b>no data will flow to any destination</b><br>If a user rejects all categories and your Segment workspace has unmapped destinations, <b>data will flow to your unmapped destinations</b></td> |
| 168 | + <td> No data loss <br><br> Device mode libraries that are passively collecting data and are mapped to categories a user does not consent to share data with might still be collecting data. <br><br><b>Segment is not able to block that data collection.</b></td> |
| 169 | + </tr> |
| 170 | + <tr> |
| 171 | + <td>Implied</td> |
| 172 | + <td>1. Website loads <br><br> 2. Segment libraries load <br><br> 3. Events flow to default consented and unmapped destinations (Segment and third-party destinations) <br><br>4. User does not interact with the consent banner and continues to access the website</td> |
| 173 | + <td>No data loss</td> |
| 174 | + </tr> |
| 175 | +</tbody> |
| 176 | +</table> |
| 177 | + |
| 178 | +<!-- TODO (IG, 4/2024): the above tables would not render ordered lists in a cell - figure out why this happened--> |
0 commit comments