Files
klevze 04a60a981e 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.
2026-09-20 14:49:34 +02:00

30 lines
993 B
PHP

{{--
<x-ad-unit slot="1234567890" />
<x-ad-unit slot="1234567890" format="rectangle" class="my-6" />
Props:
slot — AdSense ad slot ID (required)
format — AdSense data-ad-format (default: auto)
class — additional wrapper classes
Renders nothing when:
- GOOGLE_ADSENSE_PUBLISHER_ID is not set in .env
- The visitor is authenticated
- User has not given consent (handled client-side via CSS class .ads-disabled)
--}}
@php
$publisherId = config('services.google_adsense.publisher_id');
@endphp
@if($publisherId && ! auth()->check())
<div class="ad-unit-wrapper {{ $attributes->get('class', '') }}">
<ins class="adsbygoogle"
style="display:block"
data-ad-client="{{ $publisherId }}"
data-ad-slot="{{ $slot }}"
data-ad-format="{{ $format ?? 'auto' }}"
data-full-width-responsive="true"></ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
</div>
@endif