fix: streamline datalayer integration for all events
This commit is contained in:
@@ -59,22 +59,18 @@
|
||||
|
||||
{% block data_layer %}
|
||||
{% 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
|
||||
}]
|
||||
});
|
||||
<div {{ stimulus_controller('data-layer', {
|
||||
'payload': {
|
||||
'event': 'Transaction',
|
||||
'userInfo': is_granted('ROLE_USER') ? 'mitglied' : 'gast',
|
||||
'transactionId': bookingNumber,
|
||||
'transactionTotal': bookingTotal,
|
||||
'transactionProducts': [{
|
||||
'name': travelName,
|
||||
'price': bookingTotal,
|
||||
'quantity': 1
|
||||
}]
|
||||
}
|
||||
</script>
|
||||
}) }}></div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user