---
schema_version: "1"
id: c89057e92772e5477c6be46ae24ae2e37f585e29e819258796b2f5ec9c3f4119
title: Third-Party Analytics Libraries Blocked by Lightning Web Security
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lwc/lightning-components-security/guides/lws/lws-analytics.md
canonical_url: https://developer.salesforce.com/docs/platform/lightning-components-security/guide/lws-analytics.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: c4193def47f54ba378ce7c2587d83caa84a7d84fe0d52162819e375b557e8b84
products:
  - Security for Lightning Components
  - lwc
---
# Third-Party Analytics Libraries Blocked by Lightning Web Security

Analytics libraries such as Google Analytics and Adobe Analytics require access to the entire page unrestricted. This requirement conflicts with the Lightning Web Security (LWS) requirement that code belonging to one namespace isn’t allowed to access data from a different namespace.

LWS prevents the third-party analytics scripts from accessing code running in the browser outside the JavaScript sandboxes. Only platform code is allowed to run outside sandboxes. LWS also prevents analytics scripts from accessing global objects in JavaScript sandboxes because the scripts don’t belong to the namespaces reserved for the sandboxes.

Experience Cloud sites can use a workaround to enable analytics libraries to work with Lightning Locker. This approach can also work if LWS is enabled in the org instead of Lightning Locker. The workaround applies only to Experience Cloud sites because Experience Builder gives admins access to the `head` markup of the sites. Other Salesforce applications and components don’t allow such access. See the [_Experience Cloud Developer Guide_](https://developer.salesforce.com/docs/atlas.en-us.communities_dev.meta/communities_dev/communities_dev_security_locker_example.htm).
