@@ -15,10 +15,27 @@ const getCustomScripts = ():
1515
1616export default function Document ( ) {
1717 const scripts = getCustomScripts ( ) ;
18+ const gtmId = process . env . NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID ;
19+ const linkedInInsightId = process . env . NEXT_PUBLIC_LINKEDIN_INSIGHT_ID ;
1820
1921 return (
2022 < Html className = "antialiased [font-feature-settings:'ss01']" lang = "en" >
2123 < Head >
24+ { gtmId && (
25+ < script
26+ id = "gtm"
27+ type = "text/javascript"
28+ dangerouslySetInnerHTML = { {
29+ __html :
30+ `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':` +
31+ `new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],` +
32+ `j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=` +
33+ `'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);` +
34+ `})(window,document,'script','dataLayer',${ JSON . stringify ( gtmId ) } );` ,
35+ } }
36+ />
37+ ) }
38+
2239 < link
2340 rel = "apple-touch-icon"
2441 sizes = "57x57"
@@ -97,6 +114,17 @@ export default function Document() {
97114 < meta name = "theme-color" content = "#ffffff" />
98115 </ Head >
99116 < body >
117+ { gtmId && (
118+ < noscript >
119+ < iframe
120+ src = { `https://www.googletagmanager.com/ns.html?id=${ gtmId } ` }
121+ height = "0"
122+ width = "0"
123+ style = { { display : "none" , visibility : "hidden" } }
124+ />
125+ </ noscript >
126+ ) }
127+
100128 < Main />
101129 < NextScript />
102130
@@ -114,6 +142,44 @@ export default function Document() {
114142 />
115143 ) ,
116144 ) }
145+
146+ { linkedInInsightId && (
147+ < >
148+ < script
149+ id = "li-insight"
150+ type = "text/javascript"
151+ dangerouslySetInnerHTML = { {
152+ __html : `
153+ _linkedin_partner_id = ${ JSON . stringify ( linkedInInsightId ) } ;
154+ window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
155+ window._linkedin_data_partner_ids.push(_linkedin_partner_id);
156+
157+ (function(l) {
158+ if (!l){
159+ window.lintrk = function(a,b){window.lintrk.q.push([a,b])};
160+ window.lintrk.q=[]
161+ }
162+
163+ var s = document.getElementsByTagName("script")[0];
164+ var b = document.createElement("script");
165+ b.type = "text/javascript";b.async = true;
166+ b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js";
167+ s.parentNode.insertBefore(b, s);
168+ })(window.lintrk);`
169+ } }
170+ />
171+
172+ < noscript >
173+ < img
174+ height = "1"
175+ width = "1"
176+ style = { { display : "none" } }
177+ alt = ""
178+ src = { `https://px.ads.linkedin.com/collect/?pid=${ linkedInInsightId } &fmt=gif` }
179+ />
180+ </ noscript >
181+ </ >
182+ ) }
117183 </ body >
118184 </ Html >
119185 ) ;
0 commit comments