[Adsense Issue] : I put Display Ad Unit in my Next.js App alongside InFeed Ad Unit; The InFeed
Unanswered
Giant panda posted this in #help-forum
Giant pandaOP
InFeed works perfectly fine, I even checked Chrome Dev Tools and filtered Network for "ads?" and I only saw my InFeed ads trigger
but my Display Ads nor trigger nor get me any earnings if I look at my Adsense rapports
This is my code :
Am I doing something wrong ?
but my Display Ads nor trigger nor get me any earnings if I look at my Adsense rapports
This is my code :
const AdUnit = ({ children }: Props) => {
return (
<Suspense>
{isProduction ? <AdUnitClient>{children}</AdUnitClient> : <>{children}</>}
</Suspense>
);
};
export default AdUnit;
type format = "auto" | "rectangle" | "vertical" | "horizontal";
export function DisplayAdUnit({
className,
format = "auto",
}: {
className?: string;
format?: format;
}) {
return (
<div className={className}>
<AdUnit>
<ins
className="adsbygoogle"
style={{ display: "block" }}
data-ad-client={process.env.NEXT_PUBLIC_ADSENSE_PUB_ID!}
data-ad-slot="00000"
data-ad-format={format}
data-full-width-responsive="true"
></ins>
</AdUnit>
</div>
);
}
export function InFeedAdUnit({ className }: { className?: string }) {
return (
<Card className={className}>
<AdUnit>
<ins
className="adsbygoogle"
style={{ display: "block" }}
data-ad-format="fluid"
data-ad-layout-key="0000"
data-ad-client={process.env.NEXT_PUBLIC_ADSENSE_PUB_ID!}
data-ad-slot="000000"
></ins>
</AdUnit>
</Card>
);
}
declare global {
interface Window {
adsbygoogle?: any | any[];
}
}
export default function AdUnitClient({ children }: AdUnitProps) {
const pathname = usePathname();
const searchParams = useSearchParams();
useEffect(() => {
try {
(window.adsbygoogle = window.adsbygoogle || []).push({});
} catch (err) {
if (process.env.NODE_ENV !== "production") {
console.error(err);
}
}
}, [pathname, searchParams]);
return <>{children}</>;
}
Am I doing something wrong ?