{% block disco_meta_extra_information %}
{% block disco_meta_extra_information_custom_url %}
{% if config('DIScoGA4.config.customUrl') %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.ga4CustomUrl = '{{ config('DIScoGA4.config.customUrl')|raw }}';
</script>
{% else %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.ga4CustomUrl = '';
</script>
{% endif %}
{% endblock %}
{% block disco_meta_extra_information_checkout_extra %}
{% block disco_meta_extra_information_checkout_extra_shipping_method %}
{% if page.order.deliveries.first.shippingMethod is defined %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.ga4ShippingMethod = '{{ page.order.deliveries.first.shippingMethod.translated.name }}';
</script>
{% endif %}
{% endblock %}
{% block disco_meta_extra_information_checkout_extra_payment_method %}
{% if page.order.transactions.last.paymentMethod is defined %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.ga4PaymentMethod = '{{ page.order.transactions.last.paymentMethod.translated.name }}';
</script>
{% endif %}
{% endblock %}
{% block disco_meta_extra_information_checkout_extra_order_number %}
{% if page.order.orderNumber is defined %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.ga4OrderNumber = '{{ page.order.orderNumber }}';
</script>
{% endif %}
{% endblock %}
{% endblock %}
{% block disco_meta_extra_information_main %}
{% block disco_meta_extra_information_searchterm %}
{% if page.searchTerm %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.searchTerm = '{{ page.searchTerm }}';
</script>
{% endif %}
{% endblock %}
{% block disco_meta_extra_information_searchResult %}
{% if page.listing.total %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.searchResult = '{{ page.listing.total }}';
</script>
{% endif %}
{% endblock %}
{% block disco_meta_extra_information_config %}
{% block disco_meta_extra_information_config_initialisation %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.ga4RemarketingEnabled = false;
window.googleAnalyticsEnabled = false;
window.googleAdsEnabled = false;
window.ga4AdvancedAdsEnabled = false;
window.ga4Enabled = false;
window.googleTagEnabled = false;
{% if config('DIScoGA4.config.cookieConfig') %}
window.ga4CookieConfig = '{{ config('DIScoGA4.config.cookieConfig') }}';
{% else %}
window.ga4CookieConfig = "standardCookies";
{% endif %}
{% if config('DIScoGA4.config.ga4cookieListener') %}
window.ga4cookieListener = true;
{% else %}
window.ga4cookieListener = false;
{% endif %}
{% if config('DIScoGA4.config.generateLeadValue') %}
window.generateLeadValue = '{{ config('DIScoGA4.config.generateLeadValue') }}';
{% else %}
window.generateLeadValue = 0.0;
{% endif %}
window.ga4Currency = '{{ context.currency.translated.shortName }}';
{% if config('DIScoGA4.config.transationIdMethod') and config('DIScoGA4.config.transationIdMethod') == "trueOrderId" %}
window.transationIdMethod = "trueOrderId";
{% else %}
window.transationIdMethod = "hashedOrderId";
{% endif %}
{% if config('DIScoGA4.config.phoneNumberMethod') and config('DIScoGA4.config.phoneNumberMethod') == "truePhoneNumber" %}
window.phoneNumberMethod = "truePhoneNumber";
{% else %}
window.phoneNumberMethod = "hashedPhoneNumber";
{% endif %}
</script>
{% endblock %}
{% block disco_meta_extra_information_config_activation %}
{% if config('DIScoGA4.config.googleTagEnabled') and config('DIScoGA4.config.googleTagId') %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.ga4TagId = '{{ config('DIScoGA4.config.googleTagId')|raw }}';
window.dataLayer = window.dataLayer || [];
window.googleTagEnabled = true;
window.ga4Enabled = true;
window.ga4controllerName = '{{ controllerName|lower }}';
window.ga4controllerAction = '{{ controllerAction|lower }}';
window.ga4activeNavigationId = '{{ page.header.navigation.active.id }}';
window.ga4activeNavigationName = '{{ page.header.navigation.active.name }}';
window.ga4affiliation = '{{ context.salesChannel.name }}';
window.ga4salesChannelName = '{{ context.salesChannel.name }}';
window.ga4salesChannelId = '{{ context.salesChannel.id }}';
{% if config('DIScoGA4.config.enableUserId') %}
window.ga4enableUserId = true;
{% else %}
window.ga4enableUserId = false;
{% endif %}
{% if config('DIScoGA4.config.uvpPriceAsCoupon') %}
window.ga4upCoupon = true;
{% else %}
window.ga4upCoupon = false;
{% endif %}
{% if config('DIScoGA4.config.graduatedPriceAsCoupon') %}
window.ga4gpCoupon = true;
{% else %}
window.ga4gpCoupon = false;
{% endif %}
</script>
{% endif %}
{% endblock %}
{% block disco_meta_extra_information_config_google_analytics %}
{% if config('DIScoGA4.config.googleAnalyticsEnabled') %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.googleAnalyticsEnabled = true;
</script>
{% endif %}
{% endblock %}
{% endblock %}
{% block disco_meta_extra_information_usertracking %}
{% if context.customer is not null and not context.customer.guest ? 1 : 0 %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.ga4UserLoggedIn = true;
</script>
{% if config('DIScoGA4.config.enableUserId') %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.ga4UserId = '{{ context.customer.id }}';
</script>
{% endif %}
{% else %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
window.ga4UserLoggedIn = false;
if (localStorage.getItem("loginSent")) localStorage.removeItem("loginSent")
</script>
{% endif %}
{% if config('DIScoGA4.config.googleAdsEnabled') %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
{% if config('DIScoGA4.config.enableRemarketing') %}
window.ga4RemarketingEnabled = true;
{% else %}
window.ga4RemarketingEnabled = false;
{% endif %}
window.googleAdsEnabled = true;
{% if config('DIScoGA4.config.enableAdsAdvanced') %}
window.ga4AdvancedAdsEnabled = true;
{% else %}
window.ga4AdvancedAdsEnabled = false;
{% endif %}
{% if config('DIScoGA4.config.adsValueNetto') and config('DIScoGA4.config.adsValueNetto') == "netto" %}
window.adsValueNetto = true;
{% else %}
window.adsValueNetto = false;
{% endif %}
{% if config('DIScoGA4.config.transationIdMethod') and config('DIScoGA4.config.transationIdMethod') == "trueOrderId" %}
window.transationIdMethod = "trueOrderId";
{% else %}
window.transationIdMethod = "hashedOrderId";
{% endif %}
</script>
{% if context.customer is not null %}
<span class='d-none ga4-hidden-ads-information'
data-feedcountry='{{ config('DIScoGA4.config.feedCountry') }}'
data-feedlangage='{{ config('DIScoGA4.config.feedLanguage') }}' {% if config('DIScoGA4.config.enableAdsAdvanced') %} data-useremail='{{ context.customer.email }}' data-phone='{{ context.customer.activeBillingAddress.phoneNumber }}' data-firstname='{{ context.customer.activeBillingAddress.firstName }}' data-lastname='{{ context.customer.activeBillingAddress.lastName }}' data-street='{{ context.customer.activeBillingAddress.street }}' data-city='{{ context.customer.activeBillingAddress.city }}' data-region='{{ context.customer.activeBillingAddress.countryState.name }}' data-zip='{{ context.customer.activeBillingAddress.zipcode }}' data-land='{{ context.customer.activeBillingAddress.country.name }}' {% endif %}></span>
{% endif %}
{% endif %}
{% endblock %}
{% block disco_meta_extra_information_specialcase %}
<script {% if app.session.get('csp_nonce') %}nonce="{{ app.session.get('csp_nonce') }}"{% endif %}
type="text/javascript">
if (window.googleAdsEnabled !== true && window.googleAnalyticsEnabled !== true) {
window.ga4Enabled = false;
}
</script>
{% endblock %}
{% endblock %}
{% block disco_meta_extra_information_extensions %}
{% sw_include '@Storefront/storefront/ga4/ga4-products-extensions.html.twig' %}
{% endblock %}
{% block disco_hidden_line_items_information %}
{% if page.cart %}
{% set discocart= page.cart %}
{% set discolineItems = page.cart.lineItems %}
<div class="d-none discoga4-header-hidden-line-items-information"
data-currency="{{ context.currency.translated.shortName }}"
data-shipping="{{ discocart.deliveries.shippingCosts.sum().totalPrice }}"
data-value="{{ discocart.price.totalPrice }}"
data-tax="{{ discocart.price.calculatedTaxes.amount }}"
>
{% endif %}
{% if page.order %}
{% set discocart= page.order %}
{% set discolineItems = page.order.lineItems %}
<div class="d-none discoga4-header-hidden-line-items-information"
data-currency="{{ context.currency.translated.shortName }}"
data-shipping="{{ discocart.shippingTotal }}"
data-value="{{ discocart.price.totalPrice }}"
data-tax="{{ discocart.price.calculatedTaxes.amount }}"
>
{% endif %}
{% if discocart %}
{% for lineItem in discolineItems %}
{% if lineItem.priceDefinition.price %}
{% set gaPrice = lineItem.priceDefinition.price %}
{% else %}
{% set gaPrice = lineItem.price.totalPrice %}
{% endif %}
{% block disco_hidden_line_item_information %}
<span class="hidden-line-item"
data-id="{{ lineItem.id }}"
data-name="{{ lineItem.label }}"
data-type="{{ lineItem.type }}"
data-sku="{{ lineItem.payload.productNumber }}"
data-quantity="{{ lineItem.quantity }}"
data-price="{{ gaPrice }}">
</span>
{% endblock %}
{% endfor %}
</div>
{% endif %}
{% endblock %}
{% endblock %}