File tree 2 files changed +27
-16
lines changed
2 files changed +27
-16
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,22 @@ export function useScriptGoogleAdsense<T extends GoogleAdsenseApi>(_options?: Go
72
72
73
73
Please follow the [ Registry Scripts] ( /docs/guides/registry-scripts ) guide to learn more about advanced usage.
74
74
75
+ ### Site Ownership Verification
76
+
77
+ When a ` client ` is provided, a meta tag will be inserted on the page so that Google can verify your site ownership.
78
+
79
+ ``` ts
80
+ const adsense = useScriptGoogleAdsense ({
81
+ client: ' ca-pub-<your-id>' ,
82
+ })
83
+ ```
84
+
85
+ The generated meta tag will look like this:
86
+
87
+ ``` html
88
+ <meta name =" google-adsense-account" content =" ca-pub-<your-id>" >
89
+ ```
90
+
75
91
### GoogleAdsenseApi
76
92
77
93
``` ts
Original file line number Diff line number Diff line change 1
- import { optional } from 'valibot'
2
1
import { useRegistryScript } from '../utils'
3
- import { object , string } from '#nuxt-scripts-validator'
2
+ import { object , string , optional } from '#nuxt-scripts-validator'
4
3
import type { RegistryScriptInput } from '#nuxt-scripts'
5
4
import { useHead } from '#imports'
6
5
@@ -40,21 +39,17 @@ export function useScriptGoogleAdsense<T extends GoogleAdsenseApi>(_options?: Go
40
39
use ( ) {
41
40
return { adsbygoogle : window . adsbygoogle }
42
41
} ,
43
- // allow dataLayer to be accessed on the server
44
- stub : import . meta. client
45
- ? undefined
46
- : ( { fn } ) => {
47
- return fn === 'adsbygoogle' ? [ ] : undefined
48
- } ,
49
42
beforeInit ( ) {
50
- useHead ( {
51
- meta : [
52
- {
53
- name : 'google-adsense-account' ,
54
- content : options ?. client ,
55
- } ,
56
- ] ,
57
- } )
43
+ if ( options ?. client ) {
44
+ useHead ( {
45
+ meta : [
46
+ {
47
+ name : 'google-adsense-account' ,
48
+ content : options ?. client ,
49
+ } ,
50
+ ] ,
51
+ } )
52
+ }
58
53
} ,
59
54
} ,
60
55
} ) , _options )
You can’t perform that action at this time.
0 commit comments