diff --git a/src/components/layout/leadinfo-script.tsx b/src/components/layout/leadinfo-script.tsx new file mode 100644 index 000000000..5e6ebc296 --- /dev/null +++ b/src/components/layout/leadinfo-script.tsx @@ -0,0 +1,22 @@ +import { useEffect } from 'react'; + +const LeadinfoScript = () => { + useEffect(() => { + const script = document.createElement('script'); + script.innerHTML = ` + (function(l,e,a,d,i,n,f,o){if(!l[i]){l.GlobalLeadinfoNamespace=l.GlobalLeadinfoNamespace||[]; + l.GlobalLeadinfoNamespace.push(i);l[i]=function(){(l[i].q=l[i].q||[]).push(arguments)};l[i].t=l[i].t||n; + l[i].q=l[i].q||[];o=e.createElement(a);f=e.getElementsByTagName(a)[0];o.async=1;o.src=d;f.parentNode.insertBefore(o,f);} + }(window,document,'script','https://cdn.leadinfo.eu/ping.js','leadinfo','LI-66D184CC97CFD')); + `; + document.head.appendChild(script); + + return () => { + document.head.removeChild(script); + }; + }, []); + + return null; +}; + +export default LeadinfoScript; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index b6860297a..2f97547c6 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -11,6 +11,7 @@ import { } from '../types'; import { IGatsbyImageData } from 'gatsby-plugin-image'; import { StructuredOrganizationData } from '../components/pages/landingpage/structured-organization-data'; +import LeadinfoScript from '../components/layout/leadinfo-script'; // Import the new component export interface OfficeImage { relativePath: string; @@ -72,6 +73,7 @@ export const Head = ({ data, location }: PageProps) => { locales={data.locales} /> + ); };