> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: updateConsentPolicy(consentPolicy: ConsentPolicy) # Method package: wixBusinessToolsV2 # Method menu location: wixBusinessToolsV2 --> siteProperties --> updateConsentPolicy # Method Link: https://dev.wix.com/docs/velo/apis/wix-business-tools-v2/site-properties/update-consent-policy.md # Method Description: Updates a site's default consent policy. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Update Consent Policy (dashboard page code) ```javascript import { siteProperties } from 'wix-business-tools.v2'; import { elevate } from 'wix-auth'; /* Sample objectArg value: * { * advertising: true, * analytics: true, * dataToThirdParty: true, * essential: true, * functional: true * } */ export async function myUpdateConsentPolicyFunction(consentPolicy) { try { const elevatedUpdateConsentPolicy = elevate(siteProperties.updateConsentPolicy); await elevatedUpdateConsentPolicy(consentPolicy); console.log('Success! Updated policy'); return true; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */ ``` ## Update Consent Policy (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { siteProperties } from 'wix-business-tools.v2'; import { elevate } from 'wix-auth'; /* Sample objectArg value: * { * advertising: true, * analytics: true, * dataToThirdParty: true, * essential: true, * functional: true * } */ export const myUpdateConsentPolicyFunction = webMethod(Permissions.Anyone, async (consentPolicy) => { try { const elevatedUpdateConsentPolicy = elevate(siteProperties.updateConsentPolicy); await elevatedUpdateConsentPolicy(consentPolicy); console.log('Success! Updated policy'); return true; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to void */ ``` ## updateConsentPolicy - Practical Example ```javascript /*********************************************** * Backend code - update-consent-policy.web.js * **********************************************/ import { Permissions, webMethod } from 'wix-web-module'; import { siteProperties } from 'wix-business-tools.v2'; import { elevate } from 'wix-auth'; export const myUpdateConsentPolicyFunction = webMethod(Permissions.Anyone, async (consentPolicy) => { try { const elevatedUpdateConsentPolicy = elevate(siteProperties.updateConsentPolicy); await elevatedUpdateConsentPolicy(consentPolicy); console.log('Success! Updated policy'); return true; } catch (error) { console.error(error); throw new Error(error); } }); /************* * Page code * ************/ import { myUpdateConsentPolicyFunction } from 'backend/update-consent-policy.web'; $w.onReady(() => { $w('#submit').onClick(async () => { const updatedPolicy = { advertising: $w('#advertising').checked, analytics: $w('#analytics').checked, dataToThirdParty: $w('#dataToThirdParty').checked, essential: $w('#essential').checked, functional: $w('#functional').checked } const isUpdated = await myUpdateConsentPolicyFunction(updatedPolicy); if (isUpdated) { console.log('Consent policy successfully updated'); $w('#successfulUpdateMsg').show(); setTimeout(() => { $w('#successfulUpdateMsg').hide(); }, 10000); } }); }); ``` ---