feat: integrate Google AdSense with publisher ca-pub-3876936176422477
This commit is contained in:
parent
7bfdaafc10
commit
fffbb1b2ff
3 changed files with 22 additions and 16 deletions
|
|
@ -70,10 +70,11 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|||
name="google-site-verification"
|
||||
content="t_GK2K5w97K3W9jIuzdmPKGu-STw4fagx-5jYQib4yE"
|
||||
/>
|
||||
{/* Adsterra Network Script */}
|
||||
<Script
|
||||
src="https://pl31295441.profitableratecpmnetwork.com/fd/4a/91/fd4a9155d8cc10399821f613377ee9f1.js"
|
||||
strategy="afterInteractive"
|
||||
{/* Google AdSense */}
|
||||
<script
|
||||
async
|
||||
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3876936176422477"
|
||||
crossOrigin="anonymous"
|
||||
/>
|
||||
</head>
|
||||
<body className="dot-bg-fade flex min-h-full flex-col bg-black text-foreground">
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export default function AdSlot({ slot, format = "auto", className = "" }: AdSlot
|
|||
<ins
|
||||
className="adsbygoogle"
|
||||
style={{ display: "block" }}
|
||||
data-ad-client="ca-pub-XXXXXXXXXXXXXXXX"
|
||||
data-ad-client="ca-pub-3876936176422477"
|
||||
data-ad-slot={slot}
|
||||
data-ad-format={format}
|
||||
data-full-width-responsive="true"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
interface SidebarAdProps {
|
||||
slotId?: string;
|
||||
|
|
@ -8,18 +8,15 @@ interface SidebarAdProps {
|
|||
className?: string;
|
||||
}
|
||||
|
||||
export default function SidebarAd({ format = "vertical", className = "" }: SidebarAdProps) {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
export default function SidebarAd({ slotId, format = "vertical", className = "" }: SidebarAdProps) {
|
||||
useEffect(() => {
|
||||
if (!containerRef.current) return;
|
||||
try {
|
||||
const script = document.createElement("script");
|
||||
script.src = "https://pl31295441.profitableratecpmnetwork.com/fd/4a/91/fd4a9155d8cc10399821f613377ee9f1.js";
|
||||
script.async = true;
|
||||
containerRef.current.appendChild(script);
|
||||
if (typeof window !== "undefined") {
|
||||
// @ts-expect-error Google ads window object
|
||||
(window.adsbygoogle = window.adsbygoogle || []).push({});
|
||||
}
|
||||
} catch {
|
||||
// Ignore network blocks
|
||||
// Ignore if AdSense blocked by client
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
|
@ -34,7 +31,15 @@ export default function SidebarAd({ format = "vertical", className = "" }: Sideb
|
|||
Ad
|
||||
</span>
|
||||
|
||||
<div ref={containerRef} className="w-full flex items-center justify-center min-h-[250px]" />
|
||||
{/* Google AdSense Unit */}
|
||||
<ins
|
||||
className="adsbygoogle block w-full h-full"
|
||||
style={{ display: "block" }}
|
||||
data-ad-client="ca-pub-3876936176422477"
|
||||
data-ad-slot={slotId || "1234567890"}
|
||||
data-ad-format={format === "vertical" ? "vertical" : "auto"}
|
||||
data-full-width-responsive="true"
|
||||
/>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue