/** * SEO component that queries for data with * Gatsby's useStaticQuery React hook * * See: https://www.gatsbyjs.org/docs/use-static-query/ */ 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.ico'; function SEO({ lang, meta, title, slug, canonical, metadesc, keywords, social_share_summary, social_share_desc, social_share_image, noindex, }) { const { site } = useStaticQuery( graphql` query { site { siteMetadata { title description author } } } ` ); 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 ( <> {/* fav icon */} {/* fonts */} {/* */} {/* */} {/* Bootstrap */} {/* */} {/* */} {/* */} {/* canonical */} {canonical ? ( ) : ( )} {/* Algolia Instantsearch IE11 support v3 */} {/* {loadGTM && ( <> )} ); } SEO.defaultProps = { lang: 'en', meta: [], }; SEO.propTypes = { lang: PropTypes.string, meta: PropTypes.arrayOf(PropTypes.object), title: PropTypes.string.isRequired, canonical: PropTypes.string, metadesc: PropTypes.string, keywords: PropTypes.string, social_share_summary: PropTypes.string, social_share_desc: PropTypes.string, social_share_image: PropTypes.string, noindex: PropTypes.bool, }; export default SEO;