Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev to main [ 26 Oct ] #71

Merged
merged 9 commits into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 49 additions & 12 deletions src/components/seo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
* 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';
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`
Expand All @@ -37,9 +37,34 @@ 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("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');
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');
`;
document.head.appendChild(script);
}
}, []);

return (
<>
<Helmet
htmlAttributes={{
lang,
Expand Down Expand Up @@ -146,6 +171,18 @@ function SEO({ lang,
<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/23341221.js"></script>

</Helmet>
{loadGTM && (
<>
<noscript>
{`
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5F8HTVT"
height="0" width="0" style="display:none;visibility:hidden">
</iframe>
`}
</noscript>
</>
)}
</>
);
}

Expand Down