Insert Google AdSense code to all posts with Goo Include Me plugin
Here we will explain how to insert Google Adsense Ads to beginning, and at the end of every post, with the Goo Include Me plugin.
AdSense (Google AdSense) is an advertising placement service by Google. The program is designed for website publishers who want to display targeted text, video or image advertisements on website pages and earn money when site visitors view or click the ads.“
Prerequisites: Google AdSense account, familiar with creating ad units
We will need two “rules” for two ad units, one at the beginning and another at the end of the post content.
- Create two ad units via Google AdSense console
- Copy/paste first unit ad code into CODE text area of the new rule in Arbitrary HTML section of the plugin.
- Caption – google_ad_inpost_top (or something similar to this)
- Include into – singular(post)
- Placement – Content-beginning
Now, hit “Save Changes” and create another rule using the same methodology, with slight differences:
C/P second ad unit code, Caption set to “google_ad_inpost_bottom”, Include into -> “singular(post)” and Placement -> “Content-End”.
In our example, we propagate ad units ONLY in post type posts, but not page type or any other (eg. category view), which somehow makes sense, since page with contact form, usually do not contain ads at all. Anyway, to change this behavior you have to change the rule of inclusion (Include into) in both rules. Include into must be the same for both rules if you want to synchronize the display of both ads.
All your front end posts should have ads at top and bottom of the content similar to this:
…and plugin screen should look like this:
For this tutorial we used two “responsive” ad units, and stock WP “Twenty Fifteen” theme, which works fine on both desktop and mobile preview. Be aware of your theme requirements, responsiveness and design, because you might need “wrappers” around ad code you inserting. Any further explanation of CSS and HTML front end deployment of your code exceeds the scope of this tutorial.