Skip to content

Commit 1602db0

Browse files
authored
Merge pull request #4541 from segmentio/LIBWEB-1338
ad blocking in A.js 2.0
2 parents d34e0ee + c58cb20 commit 1602db0

File tree

1 file changed

+15
-0
lines changed
  • src/connections/sources/catalog/libraries/website/javascript

1 file changed

+15
-0
lines changed

src/connections/sources/catalog/libraries/website/javascript/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,21 @@ For more information, visit the [Segment localstorage-retry library](https://git
845845

846846
You can set the `debug` cookie to `analytics.js` to log debug messages from Analytics.js to the console.
847847

848+
## Ad Blocking
849+
Segment doesn't endorse bypassing ad blockers for client-side tracking. Your users have control as to what gets loaded on the page, because they can add a plugin to block third party scripts from loading, which includes Segment. As you can expect some data loss in client-side tracking, there are three routes Segment recommends you to choose from:
850+
851+
1. Honor the decision of the user to implement the ad blocker knowing that unfortunately, some data will be lost.
852+
2. Ask the customer to remove the ad blocker (for example, in the case of large, corporate customers).
853+
3. Move as many events and tracking over to a server-side library as possible, which won't run into the same limitations.
854+
855+
If the above routes don't work, Segment provides these workarounds to help with tracking and to mitigate data loss:
856+
857+
* Use the [bundle obfuscation](#bundle-obfuscation) feature. You can add an obfuscate property to the object in the second parameter, which obscures the URL from which your integrations and destination actions are loaded. This helps prevent words that are flagged by ad blockers to not be detected in your URL, enabling the integration to properly load.
858+
859+
* Create a [custom proxy](/docs/connections/sources/catalog/libraries/website/javascript/custom-proxy/). This changes the URL that Segment loads from (cdn.segment.com), as well as the outgoing requests generated when events are triggered (api.segment.io). By setting up proxies for these URLs, some ad blockers won't prevent Segment from loading, which means your events send downstream to your destinations. 
860+
861+
* Consider tracking data using one of Segment's [server-side libraries](/docs/connections/sources/#server). By using a server-side library, you no longer have to worry about ad blockers and privacy browsers preventing Segment from loading. This option may require more code to track something like a `.page()` call, since now you have to manually pass contextual information that otherwise would've been collected automatically by Analytics.js, such as `url`, `path`, `referrer`. Note that some destinations are device-mode only.
862+
848863
## Open source libraries
849864

850865
Analytics.js 2.0 includes the following open source components:

0 commit comments

Comments
 (0)