Skip to content

Commit 7b7c739

Browse files
María Paz Arrieta LandazuriMaría Paz Arrieta Landazuri
authored andcommitted
Implement comprehensive AdSense verification methods
1 parent a2ffc41 commit 7b7c739

File tree

3 files changed

+59
-5
lines changed

3 files changed

+59
-5
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>AdSense Verification</title>
5+
<meta name="google-adsense-account" content="ca-pub-5179832879235237">
6+
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5179832879235237" crossorigin="anonymous"></script>
7+
<script>
8+
(adsbygoogle = window.adsbygoogle || []).push({
9+
google_ad_client: "ca-pub-5179832879235237",
10+
enable_page_level_ads: true
11+
});
12+
</script>
13+
</head>
14+
<body>
15+
<h1>AdSense Verification Page</h1>
16+
<p>This page is used for Google AdSense verification.</p>
17+
</body>
18+
</html>

frontend/src/middleware.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { NextResponse } from 'next/server'
2+
import type { NextRequest } from 'next/server'
3+
4+
export function middleware(request: NextRequest) {
5+
const response = NextResponse.next()
6+
7+
// Add AdSense headers
8+
response.headers.set('X-Google-AdSense', 'ca-pub-5179832879235237')
9+
10+
return response
11+
}
12+
13+
export const config = {
14+
matcher: '/:path*',
15+
}

frontend/src/pages/_document.tsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default function Document() {
66
<Head>
77
{/* Meta tag verification */}
88
<meta name="google-adsense-account" content="ca-pub-5179832879235237" />
9+
<meta name="google-adsense-verification" content="ca-pub-5179832879235237" />
910

1011
{/* AdSense Script */}
1112
<script
@@ -19,11 +20,17 @@ export default function Document() {
1920
dangerouslySetInnerHTML={{
2021
__html: `
2122
(function() {
22-
window.adsbygoogle = window.adsbygoogle || [];
23-
window.adsbygoogle.push({
24-
google_ad_client: "ca-pub-5179832879235237",
25-
enable_page_level_ads: true
26-
});
23+
try {
24+
window.adsbygoogle = window.adsbygoogle || [];
25+
window.adsbygoogle.push({
26+
google_ad_client: "ca-pub-5179832879235237",
27+
enable_page_level_ads: true,
28+
overlays: {bottom: true}
29+
});
30+
console.log('AdSense initialized successfully');
31+
} catch (e) {
32+
console.error('AdSense initialization error:', e);
33+
}
2734
})();
2835
`,
2936
}}
@@ -32,6 +39,20 @@ export default function Document() {
3239
<body>
3340
<Main />
3441
<NextScript />
42+
{/* Fallback AdSense Script */}
43+
<script
44+
dangerouslySetInnerHTML={{
45+
__html: `
46+
if (!window.adsbygoogle) {
47+
var script = document.createElement('script');
48+
script.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5179832879235237';
49+
script.async = true;
50+
script.crossOrigin = 'anonymous';
51+
document.head.appendChild(script);
52+
}
53+
`,
54+
}}
55+
/>
3556
</body>
3657
</Html>
3758
)

0 commit comments

Comments
 (0)