File tree 3 files changed +20
-10
lines changed
3 files changed +20
-10
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ // add tag management code here, marketing or advertising functionality
2
+ // this file is gated by consent
Original file line number Diff line number Diff line change @@ -120,16 +120,31 @@ async function loadLazy(doc) {
120
120
* Loads everything that happens a lot later,
121
121
* without impacting the user experience.
122
122
*/
123
- function loadDelayed ( ) {
123
+ async function loadMarketingTech ( ) {
124
+ const mapStatus = ( consentStatus ) => {
125
+ if ( consentStatus === 'declineAll' ) return false ;
126
+ return true ;
127
+ } ;
128
+ const checkConsent = ( ) => {
129
+ const consentStatus = localStorage . getItem ( 'consentStatus' ) ;
130
+ if ( consentStatus !== null ) return mapStatus ( consentStatus ) ;
131
+ return new Promise ( ( resolve ) => {
132
+ // display consent banner
133
+ document . addEventListener ( 'aem:changeconsent' , ( e ) => {
134
+ localStorage . setItem ( 'consentStatus' , e . detail . consentStatus ) ;
135
+ resolve ( mapStatus ( e . detail . consentStatus ) ) ;
136
+ } ) ;
137
+ } ) ;
138
+ } ;
124
139
// eslint-disable-next-line import/no-cycle
125
- window . setTimeout ( ( ) => import ( './delayed .js' ) , 3000 ) ;
140
+ if ( await checkConsent ( ) ) import ( './marketing-tech .js' ) ;
126
141
// load anything that can be postponed to the latest here
127
142
}
128
143
129
144
async function loadPage ( ) {
130
145
await loadEager ( document ) ;
131
146
await loadLazy ( document ) ;
132
- loadDelayed ( ) ;
147
+ loadMarketingTech ( ) ;
133
148
}
134
149
135
150
loadPage ( ) ;
You can’t perform that action at this time.
0 commit comments