Keep AdSense rendering limited to anonymous visitors.

Show guest-only ad units on public pages and skip the AdSense script entirely for signed-in users.
This commit is contained in:
test
2026-09-20 14:49:34 +02:00
parent 37100ced3f
commit 17df4d0ad7
8 changed files with 135 additions and 8 deletions
+6 -2
View File
@@ -261,8 +261,8 @@
@inertiaHead
@endif
@if(config('services.google_adsense.publisher_id'))
{{-- Google AdSense — consent-gated loader --}}
@if(auth()->guest() && config('services.google_adsense.publisher_id'))
{{-- Google AdSense — guests only, consent-gated loader --}}
{{-- Script is only injected after the user accepts all cookies. --}}
{{-- If consent was given on a previous visit it fires on page load. --}}
<script>
@@ -297,6 +297,10 @@
})();
</script>
@endif
@guest
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6457864535683080" crossorigin="anonymous"></script>
@endguest
</head>
@php
$authBgRoutes = [