AdSense code on WordPress

Rauru

Registered Member
Joined
Mar 22, 2023
Messages
86
Reaction score
39
Hi, could you please help me with this?

I watched several tutorials onhow to insert the AdSense code in WordPress but they don't clarify this point:
Google website says you must paste on every page header in your website.
Is it enough to paste the code here? WordPress > appearance > theme file editor > header.php

I'm using also Google's plugin "Site Kit". It was suggested on Google website that the plugin will place the AdSense code if I enabled Auto ads in my AdSense account (what I already did):
6. Follow the instructions in the plugin. We recommend that you allow Site Kit to place the AdSense code, which will place the AdSense code for non-AMP and AMP versions of your site.
Note: To ensure that ads serve, make sure you’ve enabled Auto ads in your AdSense account. Site Kit does not have permission to make changes to your AdSense account settings.
Google source.

What should I do now?
Pasting the code on the header only?
Pasting the code on all the pages' header?
Waiting for the plugin to do it? but how long?

Thank you very much.
 
Just paste the code manually by Website Dashboard > Appearance > Theme file editor > header.php, paste the code before the </head> tag closes.
 
The first option is to manually paste the code in the header.php file located in WordPress > Appearance > Theme File Editor.

The second option is to utilize Google's Site Kit plugin, which can automatically insert the code if you've enabled Auto ads in your AdSense account. If you're using Site Kit and have enabled Auto ads in your AdSense account, you can let the plugin handle the code placement.
 
I allowed Google's plugin "Site Kit" to paste the code but i cannot see it in WordPress > appearance > theme file editor > header.php

Is that normal?

I submitted my website for review to AdSense. So now I don't know if pasting manually or wait for them to reply. Maybe the plugin pasted it somewhere else and I cannot see it?
 
Update: my AdSense account shows this message
"Verify site ownership (ticked in green)
Site Kit by Google will connect your site to AdSense."

Then I think I'll just need to wait for Google to review my website.
 
Yes, if you're using Site Kit, it's normal to not see the AdSense code in header.php. The plugin doesn't edit the theme file directly, but instead dynamically injects the code. If your AdSense dashboard shows "Site Kit will connect your site," you're good to go—just wait for the review. There's no need to manually paste it in unless you want full control.
 
Yes, that's normal. Site Kit injects the code through hooks, not editing header.php. If everything is connected in your AdSense setup in your dashboard and Auto Ads is turned on, then wait. There's no need to add anything manually unless you're doing custom placements.
 
I was able to write a function to inject the adsense ads into wordpress using chatgtp. I was able to tweak the function to do things such as // === Exclude specific pages by ID ===
 
Back
Top