Skip to content

Commit

Permalink
feat: move leadinfo into cookie consent
Browse files Browse the repository at this point in the history
  • Loading branch information
noa.santo committed Oct 30, 2024
1 parent acb22b9 commit 4a156e3
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 10 deletions.
24 changes: 23 additions & 1 deletion src/assets/locales/de/cookie-consent-translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,29 @@
{
"title": "Leistungs- und Analyse-Cookies",
"description": "Diese Cookies helfen uns zu analysieren, wie Besucher mit unserer Website interagieren, und ermöglichen es uns, die Leistung zu messen und zu verbessern. Sie sammeln Informationen in anonymer Form.",
"linkedCategory": "analytics"
"linkedCategory": "analytics",
"cookieTable": {
"headers": {
"name": "Name",
"domain": "Dienst",
"description": "Beschreibung",
"expiration": "Ablauf"
},
"body": [
{
"name": "_li_id",
"domain": "Leadinfo.com",
"description": "Leadinfo platziert zwei Cookies, die Satellytes nur Einblicke in das Verhalten auf der Website geben. Diese Cookies werden nicht mit anderen Parteien geteilt. Datenschutzerklärung von <a href=\"https://www.leadinfo.com/de/rechtliches/datenschutz/\">Leadinfo</a>",
"expiration": "_li_id wird für zwei Jahre gespeichert"
},
{
"name": "_li_ses",
"domain": "Leadinfo.com",
"description": "Leadinfo platziert zwei Cookies, die Satellytes nur Einblicke in das Verhalten auf der Website geben. Diese Cookies werden nicht mit anderen Parteien geteilt. Datenschutzerklärung von <a href=\"https://www.leadinfo.com/de/rechtliches/datenschutz/\">Leadinfo</a>",
"expiration": "_li_ses wird nur für die aktuelle Sitzung verwendet"
}
]
}
},
{
"title": "Weitere Informationen",
Expand Down
24 changes: 23 additions & 1 deletion src/assets/locales/en/cookie-consent-translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,29 @@
{
"title": "Performance and Analytics Cookies",
"description": "These cookies help us analyze how visitors interact with our website, allowing us to measure and improve performance. They collect information in an anonymous form.",
"linkedCategory": "analytics"
"linkedCategory": "analytics",
"cookieTable": {
"headers": {
"name": "Name",
"domain": "Service",
"description": "Description",
"expiration": "Expiration"
},
"body": [
{
"name": "_li_id",
"domain": "Leadinfo.com",
"description": "Leadinfo places two cookies that only provides Satellytes insights into the behaviour on the website. These cookies will not be shared with other parties. Privacy statement of <a href=\"https://www.leadinfo.com/en/privacy/\">Leadinfo</a>",
"expiration": "_li_id will be saved for two years"
},
{
"name": "_li_ses",
"domain": "Leadinfo.com",
"description": "Leadinfo places two cookies that only provides Satellytes insights into the behaviour on the website. These cookies will not be shared with other parties. Privacy statement of <a href=\"https://www.leadinfo.com/en/privacy/\">Leadinfo</a>",
"expiration": "_li_ses is only used for the current session"
}
]
}
},
{
"title": "More information",
Expand Down
10 changes: 5 additions & 5 deletions src/components/cookie-consent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as CookieConsentLib from 'vanilla-cookieconsent';
import enCookieConsentTranslations from '../assets/locales/en/cookie-consent-translations.json';
import deCookieConsentTranslations from '../assets/locales/de/cookie-consent-translations.json';
import { useTranslation } from 'react-i18next';
import LeadinfoScript from './layout/leadinfo-script';

export const CookieConsent = () => {
const { t, i18n } = useTranslation();
Expand Down Expand Up @@ -43,10 +44,9 @@ export const CookieConsent = () => {
loadAllBtn: t('iframemanager.youtube.load-all-button'),
},
de: {
notice:
'Dieser Inhalt wird von einer externen Quelle gehostet. Durch das Laden des Inhalts akzeptieren Sie die <a rel="noreferrer noopener" href="https://www.youtube.com/t/terms" target="_blank">Nutzungsbedingungen</a> von youtube.com.',
loadBtn: 'Video laden',
loadAllBtn: 'Video laden und nicht mehr fragen',
notice: t('iframemanager.youtube.notice'),
loadBtn: t('iframemanager.youtube.load-button'),
loadAllBtn: t('iframemanager.youtube.load-all-button'),
},
},
},
Expand Down Expand Up @@ -77,5 +77,5 @@ export const CookieConsent = () => {
}).then();
}, [i18n.language]);

return null;
return <LeadinfoScript />;
};
11 changes: 10 additions & 1 deletion src/components/layout/leadinfo-script.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { useEffect } from 'react';
const LeadinfoScript = () => {
useEffect(() => {
const script = document.createElement('script');
script.setAttribute('type', 'text/plain');
script.setAttribute('data-category', 'analytics');
script.setAttribute('data-service', 'Leadinfo');

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;
Expand All @@ -12,7 +16,12 @@ const LeadinfoScript = () => {
document.head.appendChild(script);

return () => {
document.head.removeChild(script);
const existingScript = document.querySelector(
'script[data-service="Leadinfo"]',
);
if (existingScript) {
document.head.removeChild(existingScript);
}
};
}, []);

Expand Down
2 changes: 0 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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;
Expand Down Expand Up @@ -73,7 +72,6 @@ export const Head = ({ data, location }: PageProps<IndexPageQueryProps>) => {
locales={data.locales}
/>
<StructuredOrganizationData />
<LeadinfoScript />
</>
);
};
Expand Down

0 comments on commit 4a156e3

Please sign in to comment.