File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,7 +91,10 @@ There are two ways to verify your site (of course you can implement both):
9191 const App = ({ Component , pageProps }) => {
9292 return (
9393 <>
94- < GoogleAdSense publisherId = " pub-XXXXXXXXXXXXXXXX" / > {/* 👈 16 digits */ }
94+ < GoogleAdSense
95+ publisherId = " pub-XXXXXXXXXXXXXXXX" // 👈 16 digits
96+ isAutoAd = {false } // 👈 true if you want to use Auto Ads
97+ / >
9598 {/* or */ }
9699 < GoogleAdSense / > {/* if NEXT_PUBLIC_ADSENSE_PUBLISHER_ID is set */ }
97100 < Component {... pageProps } / >
@@ -220,6 +223,8 @@ export default Page;
220223| Parameter | Optional | Type | Default | Description |
221224| ----------- | -------- | ------ | ------- | --------------------------------------------------------------------------------------------------- |
222225| publisherId | Yes | string | n/a | You can skip this parameter if you set the environment variable ` NEXT_PUBLIC_ADSENSE_PUBLISHER_ID ` . |
226+ | isAutoAd | Yes | boolean| false | Whether to enable Auto Ads. |
227+ | debug | Yes | boolean| false | Enable Google AdSense debug mode. |
223228
224229#### Manual AD
225230
Original file line number Diff line number Diff line change @@ -9,15 +9,18 @@ import { isPublisherId } from "./utils";
99
1010interface GoogleAdSenseProps extends Omit < ScriptProps , "src" | "id" > {
1111 publisherId ?: string ;
12+ isAutoAd ?: boolean ;
1213 debug ?: boolean ;
1314}
1415
1516/**
1617 * @param publisherId - Google AdSense publisher ID, if not provided, it will use NEXT_PUBLIC_ADSENSE_PUBLISHER_ID from .env
18+ * @param isAutoAd - Whether to enable Auto Ads
1719 * @param debug - Google AdSense debug mode
1820 */
1921export const GoogleAdSense = ( {
2022 publisherId,
23+ isAutoAd = false ,
2124 debug = false ,
2225 ...props
2326} : GoogleAdSenseProps ) : JSX . Element | null => {
@@ -37,7 +40,7 @@ export const GoogleAdSense = ({
3740 src = { `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-${ _publisherId } ${
3841 debug ? "google_console=1" : ""
3942 } `}
40- strategy = "lazyOnload"
43+ strategy = { isAutoAd ? "lazyOnload" : "afterInteractive" }
4144 crossOrigin = "anonymous"
4245 { ...props }
4346 />
You can’t perform that action at this time.
0 commit comments