Discover a simple method to integrate Google AdSense into your WordPress website and optimize its configuration for enhanced utilization, management, and outcomes.
This guide will demonstrate:
- Verifying your website within your AdSense account.
- Activating Site Authorization to prevent misuse of your AdSense code by unauthorized websites.
- Implementing automatic placement of AdSense ads for mobile and desktop visitors (known as Page-level ads).
- Testing AdSense Page-level ads.
Before proceeding, ensure you possess an approved AdSense account and have incorporated the necessary Privacy and Cookie Policy information on your website, adhering to Google AdSense policies.
Initially, let’s verify your website, a mandatory step for utilizing the QuickStart functionality. QuickStart facilitates automatic and intelligent placement of AdSense ads for both mobile and desktop users visiting your website.
- Access your Google AdSense account, navigate to Settings, and select My Sites.
- Click the Plus button.
- Enter your website address in the provided field.
- Choose Add Site to enable Google AdSense on your WordPress site.
At this juncture, consider configuring your settings to restrict AdSense display exclusively to your authorized websites.
Occasionally, external websites might scrape the content your website content, including your AdSense code, and incorporate it into their own sites.
Should this occur, and the infringing website violates Google Ads policies, it is you who could face repercussions. This precautionary measure ensures you won’t regret neglecting it in the future.
Implementing Site AdSense Authorization: Adding Google AdSense to WordPress
- Within the Manage Sites section, click the three stacked dots on the right located on the page’s side.
- Select Site Authorization.
- Enable the feature and save your changes.
Now, let’s activate automatic ad placement on your website.
Enabling Automatic Ad Placement:
- In your AdSense account, go to My Ads and select Page-level Ads.
- Activate either Anchor/overlay ads, Vignette ads, or both by toggling the sliders.
- Open your WordPress Dashboard in a new browser tab or window.
Next, obtain the necessary code for your website to finalize the setup.
It’s important to note that this code is identical to the one required from new Google Ads users during the application process. Therefore, you might already have it implemented and can proceed directly to the Testing section.
However, long-time users of Google Ads did not need to place this code during their application, necessitating these steps.
Furthermore, it’s noteworthy that this specific code can be universally applied to all pages across your websites.
For the subsequent step, we’ll create a basic plugin to embed the AdSense code on every page of your WordPress website.
Utilizing the Pluginception plugin provides a remarkably swift and straightforward plugin setup, so let’s install it first.
Installing Pluginception:
- Within your WordPress Dashboard, navigate to Plugins and select Add New.
- Enter Pluginception in the search bar.
- Click Install Now.
- Click Activate. This will introduce a new option called “Create a New Plugin” within the Plugins menu.
Creating Your Custom Plugin:
- Click the “Create a New Plugin” link.
- Assign a name to your plugin, such as “My Google AdSense Placement Plugin.”
- Select the “Create a Blank Plugin” button.
- Insert the code provided in the video tutorial or below these steps if you’re following the written instructions, into your plugin.
- Return to the “Add Google AdSense to WordPress” section.
- Click the Get Code button.
- Copy the code to your clipboard.
- Replace the “YOUR ADSENSE CODE” placeholder with the code copied from AdSense in the previous step.
- Finally, click the “Update File” button.
There are two methods to test your implementation. Let’s perform both now.
- Access your website from your desktop or laptop computer.
- Right-click anywhere on the page and select “View Source.”
- Search for the code you inserted. You can typically use the “Find” function (Ctrl+F) and enter “adsbygoogle” as one word without spaces.
- Now, let’s verify ad display on mobile devices. Open a page on your website using a high-end mobile device in portrait orientation (instead of landscape). Append “#googleads” to the end of the URL.
- Choose the ad format you wish to test and observe the results on your device.
- For vignettes, click any highlighted link on your page to confirm ad functionality.
If you encounter issues with ad display during testing, consult Google’s “Guide to testing Page-level ads” for potential explanations. Perform a Google search for “Guide to testing Page-level ads” to locate the relevant page.
Code Snippet Used in this Tutorial: Adding Google AdSense to WordPress
function my_google_adsense_placement_function() { $output=‘YOUR ADSENSE CODE’; echo $output; } add_action(‘wp_head’,‘my_google_adsense_placement_function’);
All the nexus-security WordPress themes provide a designated area within their theme options for easy code upload if you prefer an alternative approach, although both methods will yield identical results.