How to Include Google AdSense in WordPress (A Beginner's Step-by-Step Guide)
One of the simplest methods to monetise your WordPress website is with Google AdSense, which allows you to display relevant adverts and generate passive revenue. This tutorial will take you step-by-step through the full process of adding AdSense to your WordPress website if you’re just starting off.
Here is all you need to know, from creating the AdSense code snippet to uploading the ads.txt file.
Step 1: Create an AdSense account on Google
If you haven’t done, do the following:
- Visit the website https://www.google.com/adsense
- Select “Get Started.”
- Use your Google account to log in.
- Enter the details and URL of your website.
- Send in your application to be considered.
You will be able to access your AdSense dashboard after your application has been accepted.
Step 2: After approval, obtain the AdSense Code Snippet:
Open your AdSense account and log in.
After approval:
- From the menu on the left, select “Sites.”
- Choose a site that has been approved or add a new one.
- Copy the snippet of AdSense code, which is usually a <script> tag that looks like this:

<script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: “ca-pub-XXXXXXXXXXXXXXX”,
enable_page_level_ads: true
});
</script>
Change “ca-pub-XXXXXXXXXXXXXXX” to your actual publisher ID, please.
Step 3: Integrate WordPress with the AdSense Code
Any of the following techniques can be used to add this code:
First Choice: Making Use of a WordPress Plugin (Advanced)
Make use of an Insert Headers and Footers plugin:
- Go to Add New under Plugins.
- Use WPCode or WPBeginner to search for “Insert Headers and Footers.”
- Install the plugin and turn it on.
- Select Insert Headers and Footers under Settings.
- In the Header area, paste the AdSense code.
- Click “Save.”
AdSense will load on each page of your website as a result.
✅ Option 2: Manually Add Code to the Header of Your Theme
Only suggested if you have experience working with programming.
- Navigate to Theme File Editor under Appearance.
- The header.php file should open.
- Before the last </head> tag, paste your AdSense code.
- Save the document.
Step 4: Use WordPress to upload the ads.txt file
In order to validate your publisher details, Google AdSense could ask you to attach an ads.txt file. Here’s how:
What is ads.txt?
The acronym for Authorized Digital Sellers is Ads.txt. By stating who is permitted to sell ads on your website, it aids in the prevention of ad fraud.
How to Obtain Your Content in Ads.txt
Typically, your AdSense dashboard will display a message similar to this:
“Earnings at risk: To prevent a significant impact on your revenue, you must address certain issues with the ads.txt file.”
- Select the warning by clicking on it.
- A.txt file that looks like this will be available for you to download:

google.com, pub-XXXXXXXXXXXXXXX, DIRECT, f08c47fec0942fa0
The process of uploading ads.txt to WordPress
Option 1:Utilization
Make use of the Ads.txt Manager plugin:
- Go to Add New under Plugins.
- Look up “Ads.txt Manager.”
- Set it up and turn it on.
- Navigate to Ads.txt in Settings.
- Copy and paste the line from the file you downloaded.
- Save.
Option 2: Upload with FTP or File Manager
- Use FTP or cPanel to access the File Manager for your WordPress hosting account.
- Go to your website’s root directory, which is typically /public_html/.
- There, upload the ads.txt file.
- It is now available at https://todaystalk.site/ads.txt.

Step 5: Optional Ad Unit Placement
After AdSense has been validated and activated, you can:
- To allow Google to automatically place adverts, use Auto adverts.
- Or use widgets or blocks to manually
- Go to Ads > Ad Units > Display Ads in AdSense to see how to place manual ad units.
- Ad size should be set (responsive is ideal).
- Copy the HTML code that is provided.
- Navigate to Appearance > Widgets in WordPress.
- Paste the code into a Custom HTML widget.
- Preview and save your website.
In conclusion
One of the most effective ways to begin making money off of your content is to integrate Google AdSense into your WordPress website. You may guarantee a seamless setup and steer clear of potential revenue problems by properly positioning the snippet code and uploading the ads.txt file.
Begin modestly, monitor your progress, and gradually improve. Have fun making money!