Consent
The Salesforce Interactions SDK has been designed to respect user privacy and doesn’t
store or transmit data collected until it has been granted consent. If your site has existing
consent management features, those features must integrate with the SDK to signal when the user
has given consent to track.
Providing the user’s consent to the Salesforce Interactions SDK can happen either:
- During Initialization
- Calling updateConsents = (consents: Consent | Consent[]): void
1SalesforceInteractions.init({
2 consents: new Promise(resolve => {
3 // user clicks button that grants consent
4 document.getElementById('opt-in')
5 .addEventListener('click', () => {
6 resolve([{
7 provider: 'Test Provider',
8 purpose: SalesforceInteractions.ConsentPurpose.Tracking,
9 status: SalesforceInteractions.ConsentStatus.OptIn
10 }])
11 }, { once: true })
12
13 // user clicks button that revokes consent
14 document.getElementById('opt-out')
15 .addEventListener('click', () => {
16 resolve([{
17 provider: 'Test Provider',
18 purpose: SalesforceInteractions.ConsentPurpose.Tracking,
19 status: SalesforceInteractions.ConsentStatus.OptOut
20 }])
21 }, { once: true })
22
23 })
24})Consent Methods
1getConsents: ConsentWithMetadata[]Returns Consent Data with last updated and sent times.
1updateConsents = (consents: Consent | Consent[]): voidTo update consent after Initialization. For example, to call directly from your OneTrust
code:
1// when the user opts in
2SalesforceInteractions.updateConsents({
3 purpose: SalesforceInteractions.ConsentPurpose.Tracking,
4 provider: "OneTrust",
5 status: SalesforceInteractions.ConsentStatus.OptIn
6})
7
8// when the user opts out
9SalesforceInteractions.updateConsents({
10 purpose: SalesforceInteractions.ConsentPurpose.Tracking,
11 provider: "OneTrust", status:
12 SalesforceInteractions.ConsentStatus.OptOut
13})