diff --git a/site/source/components/ATInternetTracking/Tracker.ts b/site/source/components/ATInternetTracking/Tracker.ts index 914fbb7c9..e36ad630a 100644 --- a/site/source/components/ATInternetTracking/Tracker.ts +++ b/site/source/components/ATInternetTracking/Tracker.ts @@ -2,6 +2,15 @@ declare global { interface Window { pa: ATTracker + pdl: { + requireConsent: string + consent: { + defaultPreset: { + PA: string + } + products?: string[] + } + } } } diff --git a/site/source/components/TrackingProvider.tsx b/site/source/components/TrackingProvider.tsx index 307ed6a48..f3fc78bc0 100644 --- a/site/source/components/TrackingProvider.tsx +++ b/site/source/components/TrackingProvider.tsx @@ -14,11 +14,9 @@ export function TrackingProvider({ children }: { children: React.ReactNode }) { const [injected, setInjected] = useState(false) useEffect(() => { - const script = document.createElement('script') - script.src = 'https://tag.aticdn.net/piano-analytics.js' - script.type = 'text/javascript' - script.crossOrigin = 'anonymous' - script.async = true + configureConsent() + + const script = prepareScript() script.onload = () => { const siteId = import.meta.env.VITE_AT_INTERNET_SITE_ID @@ -83,3 +81,24 @@ export function TrackingProvider({ children }: { children: React.ReactNode }) { ) } + +const configureConsent = () => { + window.pdl = window.pdl || {} + window.pdl.requireConsent = 'v2' + window.pdl.consent = { + defaultPreset: { + PA: 'essential', + }, + } + window.pdl.consent.products = ['PA'] +} + +const prepareScript = (): HTMLScriptElement => { + const script = document.createElement('script') + script.src = 'https://tag.aticdn.net/piano-analytics.js' + script.type = 'text/javascript' + script.crossOrigin = 'anonymous' + script.async = true + + return script +}