feat: tracking integration with GTM and CMP

This commit is contained in:
Björn Fromme
2026-03-16 12:02:59 +01:00
parent 11ab98b3d8
commit 3957f6bd09
21 changed files with 453 additions and 51 deletions
+12
View File
@@ -0,0 +1,12 @@
<script>
window.dataLayer = window.dataLayer || [];
var consent = (window.CookieFirst && window.CookieFirst.consent) || { advertising: false };
if (consent.advertising) {
dataLayer.push({
'event':'VirtualPageview',
'virtualPageURL': '{{ url }}',
'virtualPageTitle': '{{ title }}',
'userInfo': '{{ is_granted('ROLE_USER') ? 'mitglied' : 'gast' }}'
});
}
</script>
+10
View File
@@ -8,6 +8,16 @@
<link rel="icon" href="{{ asset('build/favicon/favicon.ico') }}" sizes="32x32">
<link rel="icon" href="{{ asset('build/favicon/icon.svg') }}" type="image/svg+xml">
<link rel="apple-touch-icon" href="{{ asset('build/favicon/apple-touch-icon.png') }}">
{% if cmp_url() is not empty %}
<script src="{{ cmp_url() }}"></script>
<script type="text/plain" data-cookiefirst-category="necessary">
(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_id() }}');
</script>
{% endif %}
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}
@@ -95,6 +95,10 @@
</div>
</div>
{% include '_partials/_tracking.html.twig' with {
'url': '/trichter_Z1/schritt0_login_oder_gast',
'title': 'Login oder Gast'
} %}
{% endblock %}
{% block footer %}
-1
View File
@@ -6,7 +6,6 @@
date_id: params.dateId,
hotel_id: params.hotelId,
agency: params.agency,
theme: params.theme,
r: params.returnUrl
}) }}"
hx-trigger="load"
@@ -101,4 +101,8 @@
</div>
{{ form_rest(form) }}
{{ form_end(form) }}
{% include '_partials/_tracking.html.twig' with {
'url': '/trichter_Z1/schritt1_zimmerauswahl',
'title': 'Zimmerauswahl'
} %}
{% endblock %}
@@ -75,4 +75,8 @@
</div>
{{ form_rest(form) }}
{{ form_end(form) }}
{% include '_partials/_tracking.html.twig' with {
'url': '/trichter_Z1/schritt2_teilnehmende_leistungen',
'title': 'Teilnehmende und Leistungen'
} %}
{% endblock %}
@@ -85,4 +85,8 @@
</div>
{{ form_rest(form) }}
{{ form_end(form) }}
{% include '_partials/_tracking.html.twig' with {
'url': '/trichter_Z1/schritt3_zahlungsart',
'title': 'Zahlungsart'
} %}
{% endblock %}
@@ -567,4 +567,8 @@
</div>
{{ form_rest(form) }}
{{ form_end(form) }}
{% include '_partials/_tracking.html.twig' with {
'url': '/trichter_Z1/schritt4_uerbersicht_bestaetigung',
'title': 'Übersicht und Bestätigung'
} %}
{% endblock %}
@@ -55,4 +55,23 @@
</div>
</div>
{% if bookingTotal is not null and travelName is not null %}
<script>
window.dataLayer = window.dataLayer || [];
var consent = (window.CookieFirst && window.CookieFirst.consent) || { advertising: false };
if (consent.advertising) {
dataLayer.push({
'event': 'Transaction',
'userInfo': '{{ is_granted('ROLE_USER') ? 'mitglied' : 'gast' }}',
'transactionId': '{{ bookingNumber }}',
'transactionTotal': {{ bookingTotal }},
'transactionProducts': [{
'name': '{{ travelName|e('js') }}',
'price': {{ bookingTotal }},
'quantity': 1
}]
});
}
</script>
{% endif %}
{% endblock %}