From 75edfb4b4b608f805c461e765e0f401fac9695f7 Mon Sep 17 00:00:00 2001 From: Santhoshkumar <117272529+Santhosh-testsigma@users.noreply.github.com> Date: Fri, 20 Oct 2023 12:10:01 +0530 Subject: [PATCH 1/8] Integrated GTM script on tutorials page. --- src/components/seo.jsx | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/components/seo.jsx b/src/components/seo.jsx index ffe8fcb..1b6c4ee 100644 --- a/src/components/seo.jsx +++ b/src/components/seo.jsx @@ -5,7 +5,7 @@ * See: https://www.gatsbyjs.org/docs/use-static-query/ */ -import React from 'react'; +import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; import Helmet from 'react-helmet'; import { useStaticQuery, graphql } from 'gatsby'; @@ -37,7 +37,34 @@ function SEO({ lang, `, ); - const isIndexed = !noindex ? 'index, follow' : 'noindex, nofollow' + const isIndexed = !noindex ? 'index, follow' : 'noindex, nofollow'; + + const loadGTM = window.location.href.includes("tutorials"); + + useEffect(() => { + if (loadGTM) { + const script = document.createElement('script'); + const noscript = document.createElement('noscript'); + script.type = 'text/javascript'; + script.innerHTML = ` + (function(w,d,s,l,i){ + w[l]=w[l]||[]; + w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'}); + var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:''; + j.async=true; + j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl; + f.parentNode.insertBefore(j,f); + })(window,document,'script','dataLayer','GTM-5F8HTVT'); + `; + noscript.innerHTML = ` + + ` + document.head.appendChild(script); + document.head.appendChild(noscript); + } + }, []); return ( Date: Fri, 20 Oct 2023 12:33:40 +0530 Subject: [PATCH 2/8] fixed build error --- src/components/seo.jsx | 50 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/components/seo.jsx b/src/components/seo.jsx index 1b6c4ee..905ee29 100644 --- a/src/components/seo.jsx +++ b/src/components/seo.jsx @@ -39,31 +39,35 @@ function SEO({ lang, const isIndexed = !noindex ? 'index, follow' : 'noindex, nofollow'; - const loadGTM = window.location.href.includes("tutorials"); + let loadGTM = false; + + if (typeof window !== 'undefined') { + loadGTM = window.location.href.includes("testsigma.com") || window.location.href.includes("https://www.testsigma.com/") || window.location.href.includes("https://testsigma.com/"); + } useEffect(() => { - if (loadGTM) { - const script = document.createElement('script'); - const noscript = document.createElement('noscript'); - script.type = 'text/javascript'; - script.innerHTML = ` - (function(w,d,s,l,i){ - w[l]=w[l]||[]; - w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'}); - var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:''; - j.async=true; - j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl; - f.parentNode.insertBefore(j,f); - })(window,document,'script','dataLayer','GTM-5F8HTVT'); - `; - noscript.innerHTML = ` - - ` - document.head.appendChild(script); - document.head.appendChild(noscript); - } + if (loadGTM) { + const script = document.createElement('script'); + const noscript = document.createElement('noscript'); + script.type = 'text/javascript'; + script.innerHTML = ` + (function(w,d,s,l,i){ + w[l]=w[l]||[]; + w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'}); + var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:''; + j.async=true; + j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl; + f.parentNode.insertBefore(j,f); + })(window,document,'script','dataLayer','GTM-5F8HTVT'); + `; + noscript.innerHTML = ` + + ` + document.head.appendChild(script); + document.head.appendChild(noscript); + } }, []); return ( From 2b3b1ad188bd9283b2071d9656f1ab3bffff12dc Mon Sep 17 00:00:00 2001 From: Santhoshkumar <117272529+Santhosh-testsigma@users.noreply.github.com> Date: Fri, 20 Oct 2023 14:18:13 +0530 Subject: [PATCH 3/8] small fix --- src/components/seo.jsx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/seo.jsx b/src/components/seo.jsx index 905ee29..d97030b 100644 --- a/src/components/seo.jsx +++ b/src/components/seo.jsx @@ -42,13 +42,12 @@ function SEO({ lang, let loadGTM = false; if (typeof window !== 'undefined') { - loadGTM = window.location.href.includes("testsigma.com") || window.location.href.includes("https://www.testsigma.com/") || window.location.href.includes("https://testsigma.com/"); + loadGTM = window.location.href.includes("tutorials") || window.location.href.includes("https://www.testsigma.com/") || window.location.href.includes("https://testsigma.com/"); } useEffect(() => { if (loadGTM) { const script = document.createElement('script'); - const noscript = document.createElement('noscript'); script.type = 'text/javascript'; script.innerHTML = ` (function(w,d,s,l,i){ @@ -60,18 +59,13 @@ function SEO({ lang, f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-5F8HTVT'); `; - noscript.innerHTML = ` - - ` document.head.appendChild(script); - document.head.appendChild(noscript); } }, []); return ( - + + {loadGTM && ( + <> + + + )} + ); } From c5df4719a5818cf58109b0dcc26993a233b50a52 Mon Sep 17 00:00:00 2001 From: Santhoshkumar <117272529+Santhosh-testsigma@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:15:51 +0530 Subject: [PATCH 4/8] intend fix --- src/components/seo.jsx | 71 ++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/src/components/seo.jsx b/src/components/seo.jsx index d97030b..4c0333a 100644 --- a/src/components/seo.jsx +++ b/src/components/seo.jsx @@ -11,18 +11,18 @@ import Helmet from 'react-helmet'; import { useStaticQuery, graphql } from 'gatsby'; import favicon from './../images/favicon-new.ico'; -function SEO({ lang, - meta, - title, - slug, - canonical, - metadesc, - keywords, - social_share_summary, - social_share_desc, - social_share_image, - noindex - }) { +function SEO({ lang, + meta, + title, + slug, + canonical, + metadesc, + keywords, + social_share_summary, + social_share_desc, + social_share_image, + noindex +}) { const { site } = useStaticQuery( graphql` query { @@ -65,7 +65,7 @@ function SEO({ lang, return ( <> - + {loadGTM && ( - <> - - - )} - + <> + + + )} + ); } From 1ca4867aa578ce34d2ceeb570ff6a52e0c04d16c Mon Sep 17 00:00:00 2001 From: Santhoshkumar <117272529+Santhosh-testsigma@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:16:16 +0530 Subject: [PATCH 5/8] typo fix --- src/components/seo.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/seo.jsx b/src/components/seo.jsx index 4c0333a..77b130b 100644 --- a/src/components/seo.jsx +++ b/src/components/seo.jsx @@ -182,7 +182,7 @@ function SEO({ lang, '"@type":'+ '"ListItem",'+ '"position":'+ '2,'+ '"name":'+ '"Docs",'+ - '"item":'+ '"https://testsigma.com/docs/"'+ + '"item":'+ '"https://testsigma.com/tutorials/"'+ '},'+ '{'+ '"@type":'+ '"ListItem",'+ '"position":'+ '3,'+ From df187ece5c129f311ea2a288498742eebb8951a7 Mon Sep 17 00:00:00 2001 From: Santhoshkumar <117272529+Santhosh-testsigma@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:16:59 +0530 Subject: [PATCH 6/8] small fix --- src/components/seo.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/seo.jsx b/src/components/seo.jsx index 77b130b..0a4190a 100644 --- a/src/components/seo.jsx +++ b/src/components/seo.jsx @@ -181,7 +181,7 @@ function SEO({ lang, '},'+ '{'+ '"@type":'+ '"ListItem",'+ '"position":'+ '2,'+ - '"name":'+ '"Docs",'+ + '"name":'+ '"Tutorials",'+ '"item":'+ '"https://testsigma.com/tutorials/"'+ '},'+ '{'+ '"@type":'+ '"ListItem",'+ From a7e30153e1686c4fecd67610579d5ec5d74cd966 Mon Sep 17 00:00:00 2001 From: Santhoshkumar <117272529+Santhosh-testsigma@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:27:04 +0530 Subject: [PATCH 7/8] small fix --- src/components/seo.jsx | 66 +++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/components/seo.jsx b/src/components/seo.jsx index 0a4190a..1fede13 100644 --- a/src/components/seo.jsx +++ b/src/components/seo.jsx @@ -11,18 +11,18 @@ import Helmet from 'react-helmet'; import { useStaticQuery, graphql } from 'gatsby'; import favicon from './../images/favicon-new.ico'; -function SEO({ lang, - meta, - title, - slug, - canonical, - metadesc, - keywords, - social_share_summary, - social_share_desc, - social_share_image, - noindex -}) { +function SEO({ lang, + meta, + title, + slug, + canonical, + metadesc, + keywords, + social_share_summary, + social_share_desc, + social_share_image, + noindex + }) { const { site } = useStaticQuery( graphql` query { @@ -37,12 +37,12 @@ function SEO({ lang, `, ); - const isIndexed = !noindex ? 'index, follow' : 'noindex, nofollow'; + const isIndexed = !noindex ? 'index,follow' : 'noindex,nofollow' let loadGTM = false; if (typeof window !== 'undefined') { - loadGTM = window.location.href.includes("tutorials") || window.location.href.includes("https://www.testsigma.com/") || window.location.href.includes("https://testsigma.com/"); + loadGTM = window.location.href.includes("testsigma.com") || window.location.href.includes("https://www.testsigma.com/") || window.location.href.includes("https://testsigma.com/"); } useEffect(() => { @@ -170,25 +170,25 @@ function SEO({ lang, From 8a702d00e0f7311e2863c49cc1e4b064b60909a3 Mon Sep 17 00:00:00 2001 From: Santhoshkumar <117272529+Santhosh-testsigma@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:28:40 +0530 Subject: [PATCH 8/8] small fix --- src/components/seo.jsx | 43 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/src/components/seo.jsx b/src/components/seo.jsx index 1fede13..96955f6 100644 --- a/src/components/seo.jsx +++ b/src/components/seo.jsx @@ -12,16 +12,16 @@ import { useStaticQuery, graphql } from 'gatsby'; import favicon from './../images/favicon-new.ico'; function SEO({ lang, - meta, - title, - slug, - canonical, - metadesc, - keywords, - social_share_summary, - social_share_desc, - social_share_image, - noindex + meta, + title, + slug, + canonical, + metadesc, + keywords, + social_share_summary, + social_share_desc, + social_share_image, + noindex }) { const { site } = useStaticQuery( graphql` @@ -169,29 +169,6 @@ function SEO({ lang, - {loadGTM && (