@php
$googleTrackingSettings ??= app(\App\Services\Google\GoogleTrackingSettings::class);
$googleTrackingConfig ??= $googleTrackingSettings->config();
$googleConsentCollectionEnabled ??= $googleTrackingSettings->consentCollectionEnabled();
$googleTrackingEnabled ??= $googleTrackingSettings->enabled();
$shopifyCustomerPrivacyReady = $googleTrackingSettings->shopifyCustomerPrivacyReady();
$googleCrossDomainHosts = array_values(array_unique(array_filter([
...$googleTrackingConfig['cross_domain_hosts'],
...($shopifyCustomerPrivacyReady ? [$googleTrackingConfig['shopify_checkout_root_domain']] : []),
])));
$googleTrackingClientConfig = [
'tagEnabled' => $googleTrackingEnabled,
'consentCollectionEnabled' => $googleConsentCollectionEnabled,
'mode' => $googleTrackingConfig['mode'],
'gtmContainerId' => $googleTrackingConfig['gtm_container_id'],
'ga4MeasurementId' => $googleTrackingConfig['ga4_measurement_id'],
'googleAdsId' => $googleTrackingConfig['google_ads_id'],
'orderConversionDestination' => $googleTrackingSettings->orderConversionDestination(),
'leadConversionDestination' => $googleTrackingSettings->leadConversionDestination(),
'enhancedConversions' => $googleTrackingConfig['enhanced_conversions'],
'dynamicRemarketing' => $googleTrackingConfig['dynamic_remarketing'],
'consentBannerEnabled' => $googleConsentCollectionEnabled,
'consentCookieName' => \App\Services\Google\GoogleConsent::COOKIE_NAME,
'consentVersion' => \App\Services\Google\GoogleConsent::COOKIE_VERSION,
'consentReceiptUrl' => route('privacy.google-consent.store'),
'consentCsrfToken' => csrf_token(),
'consentPageNonce' => (string) request()->attributes->get(\App\Services\Google\GoogleConsentPageRegistry::REQUEST_ATTRIBUTE, ''),
'consentPagePath' => (string) request()->attributes->get(\App\Services\Google\GoogleConsentPageRegistry::REQUEST_PATH_ATTRIBUTE, '/'),
'crossDomainHosts' => $googleCrossDomainHosts,
'shopifyCustomerPrivacy' => $shopifyCustomerPrivacyReady ? [
'checkoutRootDomain' => $googleTrackingConfig['shopify_checkout_root_domain'],
'storefrontRootDomain' => $googleTrackingConfig['shopify_storefront_root_domain'],
'storefrontAccessToken' => $googleTrackingConfig['shopify_storefront_access_token'],
] : null,
];
$googleTrackingPrimaryId = $googleTrackingConfig['ga4_measurement_id'] ?: $googleTrackingConfig['google_ads_id'];
@endphp
@if ($googleConsentCollectionEnabled)
@if ($shopifyCustomerPrivacyReady)
@endif
@endif