Skip to contentSkip to navigationSkip to topbar
On this page
Looking for more inspiration?Visit the
(information)
You're in the right place! Segment documentation is now part of Twilio Docs. The content you are used to is still here—just in a new home with a refreshed look.

Analytics.js OneTrust Wrapper


FREE x
TEAM x
BUSINESS
ADDON x

This guide to Segment's Analytics.js OneTrust wrapper contains context about which configurations might cause data loss, steps you can take to remediate data loss, configurations that minimize data loss, and a guide to expected wrapper behavior.

For questions about OneTrust Consent and Preference Management behavior, see the OneTrust documentation(link takes you to an external page).

For questions about the Analytics.js OneTrust wrapper, see the @segment/analytics-consent-wrapper-onetrust(link takes you to an external page) repository.

Possibility for data loss

possibility-for-data-loss page anchor

Segment has evaluated a combination of banner behaviors, consent models, and load orders to be at either a low or medium possibility of data loss.

Low

low page anchor

Segment assesses some behaviors to have a low possibility of data loss 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 your site assumes that a user consents (if you set your cookie banner on your site to be optional and never displayed to a user).

Segment assesses 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 possibility for data loss and noncompliance.

  • 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 third-party library poses a risk only if the third-party library is collecting data in addition to collecting Segment events.
  • Possibility of data loss: 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.

To minimize the possibilities for data loss:

  • 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
  • If using cookie banners that either always remain as a user navigates your site or disappear after a user action, like clicking or scrolling:
    • 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.
    • Regularly audit your device mode libraries. Audit your device mode libraries to confirm they are not capturing data themselves.
    • 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.
(information)

Refreshing a page when a user's consent changes can 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 possibility of data loss in your downstream destinations.


Segment library desired behavior

segment-library-desired-behavior page anchor
Banner behaviorCookie bannerUser interaction with webpageSegment loadsPossibility of data loss
MandatoryDisplayed on page loadRequired to access webpageAfter user actionLow, until a user changes their preferences
A banner that always remains as a user navigates your siteDisplayed on page loadNot required to access webpageWith page loadMedium
A banner that disappears after a user action, like clicking or scrollingDisplayed on page loadNot required to access webpageWith page loadMedium
A banner that is optional and never displayed to a userNot displayed on page loadNot required to access webpageWith page loadLow, until a user changes their preferences

Scenarios where you might experience data loss

scenarios-where-you-might-experience-data-loss page anchor

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.

(information)

Info

Return users with no valid prior session are treated as first time users.

User's interaction with the bannerUser's engagement with the site after interacting with the bannerWebsite behaviorPotential for data loss
Opt-In (optional banner behavior)User provides consent preferences and closes banner (with or without the presence of strictly necessary category)1. Website loads

2. Website presents consent banner to a user

3. Users provide consent preference and close banner

4. Segment libraries load

5. Any events in the buffer for that session are sent to consented destinations (Segment and third-party destinations)

6. All events after a user provides their consent will flow to consented destinations (Segment and third-party destinations)
Data loss is possible if the user navigates away from the landing page before providing consent or if a user closes the banner.

No data loss if the user provides consent on the landing page
User does not interact with the consent banner and continues to access the website1. Website loads

2. Website presents consent banner to a user

3. User does not take a consent action and continues to access the website

4. No Segment cookies are set

5. No events flow to Segment or third-party destinations
Data loss. No data flows to strictly necessary or unmapped destinations
User rejects all cookies and closes banner1. Website loads

2. Website presents consent banner to a user

3. User rejects all cookies and closes banner

4. If workspace has unmapped destinations or strictly necessary destinations, Segment libraries load

5. Any events in the buffer for that session are sent to unmapped or strictly necessary destinations

6. All events after a user rejects consent flow to unmapped or strictly necessary destinations
Data loss is possible if the user navigates away from the landing page before providing consent or if a user closes the banner.

No data loss if the user provides consent on the landing page
Opt-In (with mandatory consent banner)User provides consent preferences and closes banner1. Website loads

2. Website presents consent banner to a user, who cannot use your website until they interact with the banner

3. User provides consent preferences and closes banner

4. Segment libraries load

5. All events flow to consented destinations (Segment and third-party destinations)
No data loss
Opt-outUser provides consent preference and closes banner1. Website loads

2. Segment libraries load

3. Events flow to default consented and unmapped destinations (Segment and third party destinations)

4. Website presents consent banner to a user

5. User provides consent preferences and closes banner

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
No data loss

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.

Segment is not able to block that data collection.
User does not interact with the consent banner and continues to access the website1. Website loads

2. Segment libraries load

3. Events flow to default consented and unmapped destinations (Segment and third-party destinations)

4. Website presents consent banner to a user

5. User does not interact with the consent banner and continues to access the website

6. Events continue to flow to default consented and unmapped destinations
No data loss
User provides consent preferences, rejects all categories, and closes the banner1. Website loads

2. Segment libraries load

3. Events flow to default consented destinations (Segment and third-party destinations)

4. Website presents consent banner to a user

5. User provides consent preferences, rejects all categories and closes the banner.


If your workspace has no unmapped or strictly necessary destinations, all event data after a user provides their consent data is blocked.


If your workspace has unmapped or strictly necessary destinations, events continue to flow to destinations in the strictly necessary category and unmapped destinations.
No data loss

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.

Segment is not able to block that data collection.
ImpliedUser does not interact with the consent banner and continues to access the website1. Website loads

2. Segment libraries load

3. Events flow to default consented and unmapped destinations (Segment and third-party destinations)

4. Website presents consent banner to a user

5. User does not interact with the consent banner and continues to access the website

6. Events continue to flow to all connected destinations


If your workspace has unmapped or strictly necessary destinations, events continue to flow to unmapped destinations.
No data loss
User's interaction with the bannerUser's engagement with the site after interacting with the bannerWebsite behaviorPotential for data loss
Opt-In*(with mandatory or optional consent banner)*User does nothing and continues accessing the website1. Website loads

2. Segment libraries load

3. Events flow to default consented and unmapped destinations (Segment and third-party destinations)

4. User does not interact with the consent banner and continues to access the website
No data loss
User seeks, opens, and updates cookies on the banner, then closes the banner1. Website loads

2. Segment libraries load

3. Events flow to default consented destinations (Segment and third-party destinations)

4. User seeks, opens, and updates cookies on the banner

5. User closes banner

6. Events flow to consented destinations, are block from flowing to mapped, non-consented destinations.
If a user rejects all categories and your Segment workspace has no unmapped destinations, no data will flow to any destination
If a user rejects all categories and your Segment workspace has unmapped destinations, data will flow to your unmapped destinations
No data loss

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.

Segment is not able to block that data collection.
Opt-out*(with mandatory or optional consent banner)*User does nothing and continues accessing the website1. Website loads

2. Segment libraries load

3. Events flow to default consented and unmapped destinations (Segment and third-party destinations)

4. User does not interact with the consent banner and continues to access the website
No data loss
User seeks, opens, and updates cookies on the banner, then closes the banner1. Website loads

2. Segment libraries load

3. Events flow to default consented destinations (Segment and third-party destinations)

4. User seeks, opens, and updates cookies on the banner

5. User closes banner

6. Events flow to consented destinations, are block from flowing to mapped, non-consented destinations.
If a user rejects all categories and your Segment workspace has no unmapped destinations, no data will flow to any destination
If a user rejects all categories and your Segment workspace has unmapped destinations, data will flow to your unmapped destinations
No data loss

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.

Segment is not able to block that data collection.
ImpliedUser does nothing and continues accessing the website1. Website loads

2. Segment libraries load

3. Events flow to default consented and unmapped destinations (Segment and third-party destinations)

4. User does not interact with the consent banner and continues to access the website
No data loss
User seeks, opens, and updates cookies on the banner, then closes the banner1. Website loads

2. Segment libraries load

3. Events flow to default consented destinations (Segment and third-party destinations)

4. User seeks, opens, and updates cookies on the banner

5. User closes banner

6. Events flow to consented destinations, are block from flowing to mapped, non-consented destinations.
If a user rejects all categories and your Segment workspace has no unmapped destinations, no data will flow to any destination
If a user rejects all categories and your Segment workspace has unmapped destinations, data will flow to your unmapped destinations
No data loss

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.

Segment is not able to block that data collection.

Expected wrapper behavior

expected-wrapper-behavior page anchor

The following table explains how Segment's OneTrust wrapper works with different configurations of consent categories and destination behaviors.

Consent categoriesUnmapped destinationsMapped destinationsWrapper behavior
All categories are disabledNo unmapped destinations
or
All unmapped destinations are disabled
Any configurationNo data flows to Segment
All categories are disabledAt least 1 enabled destination is not mapped to a consent categoryAny configurationData flows to Segment
All categories are disabledS3 destination is unmappedAny configurationData flows to Segment
One or more categories are enabledNo unmapped destinations
or
All unmapped destinations are disabled
All destinations are disabledNo data flows to Segment
One or more categories are enabledNo unmapped destinations
or
All unmapped destinations are disabled
One or more destinations are enabledData flows to Segment
One or more categories are enabledOne or more destinations are enabledAll destinations are disabledData flows to Segment
One or more categories are enabledOne or more destinations are enabledOne or more destinations are enabledData flows to Segment