Privacy JavaScript Library
The Privacy JavaScript Library is a set of tools to help create a process for accessing and deleting private data collected by Adobe Commerce and Magento Open Source.
Commerce data tracking services can store private information applicable to privacy regulations such as the General Data Protection Regulation (GDPR) and California Consumer Privacy Act (CCPA).
This library provides a set of functions for creating privacy data requests and gathering their responses. Use this library to retrieve and remove the data stored in the browser by Adobe Commerce and Magento Open Source data tracking services.
Installation
The Privacy JavaScript Library is available at the following CDN location: commerce.adobe.net/magentoprivacy.js
After you have the file, you will need to add it to a custom module or theme installed in your Adobe Commerce or Magento Open Source instance. Follow the instructions described in the Use custom JavaScript topic to accomplish this task.
Initialization
Import and instantiate a new MagentoPrivacy
object or use the window
object to access the Privacy JavaScript functions.
Example using import
:
import MagentoPrivacy from "./MagentoPrivacy"
const magePriv = new MagentoPrivacy()
Example using window
:
const magePriv = new window.MagentoPrivacy()
Usage
The Privacy JS Library provides various functions to manage identity data stored in the browser.
-
retrieveIdentity()
Returns a JavaScript promise for an identity object from a service in the browser.
magePriv.retrieveIdentity().then((ids)=>console.log(ids)) // {"value":"1ccfd8c2-5159-433c-98d7-e937ce3b13f3"}
-
removeIdentity()
Removes the identity data from a service in the browser.
This function returns a JavaScript promise for an identity object with anisDeleted
boolean property to indicate whether the data has been deleted.magePriv.removeIdentity().then((ids)=>console.log(ids)) // {"value":"1ccfd8c2-5159-433c-98d7-e937ce3b13f3","isDeleted":true}