Skip to content

Commit 2052188

Browse files
authored
Removed cookies page and changed the way google analytics script is initialized (#1797)
1 parent 8ccc107 commit 2052188

4 files changed

Lines changed: 11 additions & 90 deletions

File tree

web/landing/assets/controllers/cookie_consent_controller.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ export default class extends Controller {
4141
});
4242
this.hideBanner();
4343
this.showButton();
44-
window.location.href = '/cookies';
4544
}
4645

4746
consentGranted() {
48-
gtag("consent", "update", {
49-
analytics_storage: 'granted'
50-
});
47+
if (document.querySelector('script[src="https://www.googletagmanager.com/gtag/js?id=' + this.gaIdValue + '"]')) {
48+
return;
49+
}
50+
51+
const script = document.createElement('script');
52+
script.async = true;
53+
script.src = 'https://www.googletagmanager.com/gtag/js?id=' + this.gaIdValue;
54+
document.head.appendChild(script);
55+
56+
gtag("consent", "update", {analytics_storage: 'granted'});
57+
gtag('js', new Date());
5158
}
5259

5360
showBanner() {

web/landing/src/Flow/Website/Controller/HomeController.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ public function __construct(
1616
) {
1717
}
1818

19-
#[Route('/cookies', name: 'cookies', options: ['sitemap' => false])]
20-
public function cookies() : Response
21-
{
22-
return $this->render('main/cookies.html.twig', [
23-
]);
24-
}
25-
2619
#[Route('/', name: 'home', options: ['sitemap' => true])]
2720
public function home() : Response
2821
{

web/landing/templates/base.html.twig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
{% endblock %}
3838

3939
{% block tracking %}
40-
<script async src="https://www.googletagmanager.com/gtag/js?id={{ google_analytics_id }}"></script>
4140
<script>
4241
window.dataLayer = window.dataLayer || [];
4342
function gtag() {
@@ -49,7 +48,6 @@
4948
ad_storage: 'denied',
5049
analytics_storage: 'denied'
5150
});
52-
gtag('js', new Date());
5351
gtag('config', '{{ google_analytics_id }}');
5452
</script>
5553
{% endblock %}

web/landing/templates/main/cookies.html.twig

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)