55 * See: https://www.gatsbyjs.org/docs/use-static-query/
66 */
77
8- import React from 'react' ;
8+ import React , { useEffect } from 'react' ;
99import PropTypes from 'prop-types' ;
1010import Helmet from 'react-helmet' ;
1111import { useStaticQuery , graphql } from 'gatsby' ;
1212import favicon from './../images/favicon-new.ico' ;
1313
1414function SEO ( { lang,
15- meta,
16- title,
17- slug,
18- canonical,
19- metadesc,
20- keywords,
21- social_share_summary,
22- social_share_desc,
23- social_share_image,
24- noindex
15+ meta,
16+ title,
17+ slug,
18+ canonical,
19+ metadesc,
20+ keywords,
21+ social_share_summary,
22+ social_share_desc,
23+ social_share_image,
24+ noindex
2525 } ) {
2626 const { site } = useStaticQuery (
2727 graphql `
@@ -37,9 +37,34 @@ function SEO({ lang,
3737 ` ,
3838 ) ;
3939
40- const isIndexed = ! noindex ? 'index, follow' : 'noindex, nofollow'
40+ const isIndexed = ! noindex ? 'index,follow' : 'noindex,nofollow'
41+
42+ let loadGTM = false ;
43+
44+ if ( typeof window !== 'undefined' ) {
45+ loadGTM = window . location . href . includes ( "testsigma.com" ) || window . location . href . includes ( "https://www.testsigma.com/" ) || window . location . href . includes ( "https://testsigma.com/" ) ;
46+ }
47+
48+ useEffect ( ( ) => {
49+ if ( loadGTM ) {
50+ const script = document . createElement ( 'script' ) ;
51+ script . type = 'text/javascript' ;
52+ script . innerHTML = `
53+ (function(w,d,s,l,i){
54+ w[l]=w[l]||[];
55+ w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
56+ var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
57+ j.async=true;
58+ j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
59+ f.parentNode.insertBefore(j,f);
60+ })(window,document,'script','dataLayer','GTM-5F8HTVT');
61+ ` ;
62+ document . head . appendChild ( script ) ;
63+ }
64+ } , [ ] ) ;
4165
4266 return (
67+ < >
4368 < Helmet
4469 htmlAttributes = { {
4570 lang,
@@ -146,6 +171,18 @@ function SEO({ lang,
146171 < script type = "text/javascript" id = "hs-script-loader" async defer src = "//js.hs-scripts.com/23341221.js" > </ script >
147172
148173 </ Helmet >
174+ { loadGTM && (
175+ < >
176+ < noscript >
177+ { `
178+ <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5F8HTVT"
179+ height="0" width="0" style="display:none;visibility:hidden">
180+ </iframe>
181+ ` }
182+ </ noscript >
183+ </ >
184+ ) }
185+ </ >
149186 ) ;
150187}
151188
0 commit comments