@@ -71,28 +71,46 @@ function MyApp({Component, pageProps}: AppProps) {
71
71
72
72
return (
73
73
< >
74
- { isProd ? (
75
- < >
76
- < Script
77
- async
78
- src = { `https://www.googletagmanager.com/gtag/js?id=${ PUBLIC_GA_ID } ` }
79
- />
80
- < Script
81
- id = "gtag-init"
82
- strategy = "afterInteractive"
83
- dangerouslySetInnerHTML = { {
84
- __html : `
85
- window.dataLayer = window.dataLayer || [];
86
- function gtag(){dataLayer.push(arguments);}
87
- gtag('js', new Date());
88
- gtag('config', '${ PUBLIC_GA_ID } ', {
89
- page_path: window.location.pathname,
74
+ < Script
75
+ id = "dux-init"
76
+ strategy = "afterInteractive"
77
+ dangerouslySetInnerHTML = { {
78
+ __html : `
79
+ const loadScript = (src) => {
80
+ const promise = new Promise((resolve, reject) => {
81
+ const script = document.createElement('script');
82
+ script.src = src;
83
+ script.type = 'module';
84
+ script.onload = () => {
85
+ resolve(true);
86
+ };
87
+ script.onerror = () => {
88
+ reject(false);
89
+ };
90
+ document.body.appendChild(script);
91
+ });
92
+ return promise;
93
+ }
94
+ // example loading from CDN
95
+ loadScript('https://cdn.shopify.com/shopifycloud/dux/dux-portal-4.4.0.min.js').then(() => {
96
+ Dux.init({
97
+ eventHandlerEndpoint: 'https://www.shopify.com/__dux',
98
+ mode: 'production',
99
+ service: 'polaris-react',
100
+ enableActiveConsent: true,
101
+ enableConsentBuffer: true,
102
+ enableLogger: {
103
+ cookieBlocker: true,
104
+ },
105
+ countryCode: 'GB',
106
+ enableGtm: true,
107
+ enableGtmLoader: true,
108
+ gtmAccountId: '${ PUBLIC_GA_ID } ',
109
+ })
90
110
});
91
111
` ,
92
- } }
93
- />
94
- </ >
95
- ) : null }
112
+ } }
113
+ />
96
114
97
115
< script dangerouslySetInnerHTML = { { __html : noflash } } > </ script >
98
116
0 commit comments