Skip to content

Commit 5fab9aa

Browse files
feat(blog): enable and customize cookies (#295)
1 parent af37d1b commit 5fab9aa

File tree

3 files changed

+68
-4
lines changed

3 files changed

+68
-4
lines changed

apps/blog/src/app/providers/tracking/cookie-consent.config.ts

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ export const cookieConsentConfig = {
4747
consentModal: {
4848
title: 'We use cookies',
4949
description:
50-
'We use cookies to enhance your experience on our website. You can manage your preferences below.',
50+
'Hello, Angular Enthusiast! We use cookies on our website to provide content that best suits your interests and brings you the most value. By accepting all cookies, you allow us to learn more about the topics you prefer, enabling us to tailor our content to your needs. Thank you for joining us and helping to grow the Angular community.<br><br>You can also manage your preferences below.',
5151
acceptAllBtn: 'Accept all',
52-
acceptNecessaryBtn: 'Reject all',
5352
showPreferencesBtn: 'Manage Individual preferences',
5453
},
5554
preferencesModal: {
@@ -62,7 +61,7 @@ export const cookieConsentConfig = {
6261
{
6362
title: 'Somebody said ... cookies?',
6463
description:
65-
'We use cookies to enhance your experience on our website. Some cookies are necessary for the website to function properly, while others help us improve your experience by providing insights into how the site is being used.',
64+
'Hello, Angular Enthusiast! We use cookies on our website to provide content that best suits your interests and brings you the most value. By accepting all cookies, you allow us to learn more about the topics you prefer, enabling us to tailor our content to your needs. Thank you for joining us and helping to grow the Angular community.<br><br>You can also manage your preferences below.',
6665
},
6766
{
6867
title: 'Strictly Necessary Cookies',
@@ -90,6 +89,59 @@ export const cookieConsentConfig = {
9089
],
9190
},
9291
},
92+
pl: {
93+
consentModal: {
94+
title: 'Używamy plików cookie',
95+
description:
96+
'Używamy plików cookie na naszej stronie, aby dostarczać treści, które najlepiej odpowiadają Twoim zainteresowaniom i przynoszą Ci najwięcej korzyści. Akceptując wszystkie pliki cookie, pozwalasz nam lepiej poznać tematy, które Cię interesują, co umożliwia nam dostosowanie treści do Twoich potrzeb. Dziękujemy za dołączenie do nas i pomoc w rozwoju społeczności Angulara.<br><br>Możesz także zarządzać swoimi preferencjami poniżej.',
97+
acceptAllBtn: 'Zaakceptuj wszystkie',
98+
showPreferencesBtn: 'Zarządzaj indywidualnymi preferencjami',
99+
},
100+
preferencesModal: {
101+
title: 'Zarządzaj preferencjami plików cookie',
102+
acceptAllBtn: 'Zaakceptuj wszystkie',
103+
acceptNecessaryBtn: 'Odrzuc wszystkie',
104+
savePreferencesBtn: 'Zaakceptuj wybrane',
105+
closeIconLabel: 'Zamknij zaawansowane ustawienia',
106+
sections: [
107+
{
108+
title: 'Czy ktoś powiedział... ciasteczka?',
109+
description:
110+
'Używamy plików cookie na naszej stronie, aby dostarczać treści, które najlepiej odpowiadają Twoim zainteresowaniom i przynoszą Ci najwięcej korzyści. Akceptując wszystkie pliki cookie, pozwalasz nam lepiej poznać tematy, które Cię interesują, co umożliwia nam dostosowanie treści do Twoich potrzeb. Dziękujemy za dołączenie do nas i pomoc w rozwoju społeczności Angulara.<br><br>Możesz także zarządzać swoimi preferencjami poniżej.',
111+
},
112+
{
113+
title: 'Niezbędne pliki cookie',
114+
description:
115+
'Te pliki cookie są niezbędne do prawidłowego funkcjonowania strony i nie można ich wyłączyć.',
116+
linkedCategory: 'necessary',
117+
},
118+
{
119+
title: 'Wydajność i analityka',
120+
description:
121+
'Te pliki cookie zbierają informacje o tym, w jaki sposób korzystasz z naszej witryny. Wszystkie dane są anonimowe i nie pozwalają na identyfikację użytkownika. Pomagają nam zrozumieć, w jaki sposób odwiedzający wchodzą w interakcję z naszą witryną, co pozwala nam ulepszać nasz kontent i wygodę użytkownika.',
122+
linkedCategory: 'analytics',
123+
},
124+
{
125+
title: 'Marketing',
126+
description:
127+
'Te pliki cookie służą do śledzenia osób odwiedzających strony internetowe. Celem jest wyświetlanie spersonalizowanych reklam, a tym samym bardziej wartościowych dla wydawców i zewnętrznych reklamodawców.',
128+
linkedCategory: 'marketing',
129+
},
130+
{
131+
title: 'Więcej informacji',
132+
description:
133+
'W przypadku jakichkolwiek pytań związanych z naszą polityką dotyczącą plików cookie i Twoimi wyborami, skontaktuj się z nami.',
134+
},
135+
],
136+
},
137+
},
138+
},
139+
},
140+
guiOptions: {
141+
consentModal: {
142+
layout: 'bar',
143+
position: 'bottom',
93144
},
94145
},
146+
disablePageInteraction: true,
95147
} satisfies CookieConsentConfig;

apps/blog/src/app/providers/tracking/tracking.provider.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';
22

33
import {
4+
consentUpdateScript,
45
gtmScript,
6+
initialConsentScript,
57
metaPixel,
68
metaScript,
79
provideTracking,
@@ -31,7 +33,15 @@ export const provideAppTracking = (): EnvironmentProviders => {
3133
],
3234
},
3335
cookieConsent: cookieConsentConfig,
34-
scripts: [gtmScript('GTM-5XNT5NS'), metaScript('284876369340184')],
36+
scripts: [
37+
initialConsentScript(),
38+
gtmScript('GTM-5XNT5NS'),
39+
consentUpdateScript('ads', 'ad_storage', 'granted'),
40+
consentUpdateScript('ads', 'ad_storage', 'denied'),
41+
consentUpdateScript('analytics', 'analytics_storage', 'granted'),
42+
consentUpdateScript('analytics', 'analytics_storage', 'denied'),
43+
metaScript('284876369340184'),
44+
],
3545
pixels: [metaPixel('284876369340184')],
3646
}),
3747
]);

libs/blog/tracking/feature/src/lib/tracking.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '@angular/core';
99
import type { CookieConsentConfig } from 'vanilla-cookieconsent';
1010

11+
import { provideCookieConsent } from './cookie-consent/cookie-consent.provider';
1112
import {
1213
PartyTownConfig,
1314
PartyTownService,
@@ -42,6 +43,7 @@ export const provideTracking = (
4243
useClass: ScriptsLoaderService,
4344
},
4445
]),
46+
provideCookieConsent(config.cookieConsent),
4547
{
4648
provide: APP_INITIALIZER,
4749
multi: true,

0 commit comments

Comments
 (0)