@@ -62,26 +62,28 @@ function Gad({
62
62
const adId = adSlot . id
63
63
64
64
React . useEffect ( ( ) => {
65
- window . googletag . cmd . push ( function ( ) {
66
- // Define all ad slots
67
- const slot = window . googletag
68
- . defineSlot ( '/23278945940/TopLevel' , adSlot . sizes , adSlot . id )
69
- . addService ( window . googletag . pubads ( ) )
70
- . setTargeting ( adSlot . targeting , [ adSlot . targeting ] )
65
+ if ( window . googletag ) {
66
+ window . googletag . cmd . push ( function ( ) {
67
+ // Define all ad slots
68
+ const slot = window . googletag
69
+ . defineSlot ( '/23278945940/TopLevel' , adSlot . sizes , adSlot . id )
70
+ . addService ( window . googletag . pubads ( ) )
71
+ . setTargeting ( adSlot . targeting , [ adSlot . targeting ] )
71
72
72
- window . googletag . pubads ( ) . enableSingleRequest ( )
73
- window . googletag . enableServices ( )
74
- window . googletag . display ( adId )
73
+ window . googletag . pubads ( ) . enableSingleRequest ( )
74
+ window . googletag . enableServices ( )
75
+ window . googletag . display ( adId )
75
76
76
- // // Set individual refresh intervals for each ad
77
- // const interval = setInterval(function () {
78
- // window.googletag.cmd.push(function () {
79
- // window.googletag.pubads().refresh([slot])
80
- // })
81
- // }, slot.refreshInterval)
77
+ // // Set individual refresh intervals for each ad
78
+ // const interval = setInterval(function () {
79
+ // window.googletag.cmd.push(function () {
80
+ // window.googletag.pubads().refresh([slot])
81
+ // })
82
+ // }, slot.refreshInterval)
82
83
83
- // return () => clearInterval(interval)
84
- } )
84
+ // return () => clearInterval(interval)
85
+ } )
86
+ }
85
87
} , [ ] )
86
88
87
89
return (
0 commit comments