Thursday 12 November 2015

Insert code for AdSense Plugin for WordPress

Use this article if you need to manually insert code for AdSense placements into the HTML of your WordPress site. This way you can add placements and manage them with the AdSense Plugin for WordPress even if the plugin did not detect every spot on your site where placements might be an option.
Normally, you can just review your site with the plugin and click placement markers  in each place where you want to show ads. This is the easiest way to manage AdSense ads with our plugin. But if you don't see a placement marker in exactly the spot you need, you can add our placement code manually. After that, the plugin will show a marker in the corresponding location, and you will always have the option to insert a placement there with the plugin, or to remove or modify the placement. No additional code changes should be necessary.
Before you get started, keep this in mind:
  • Manual insertion is best for advanced users who feel comfortable working with things like HTML code and PHP files.
  • Our plugin is designed to help prevent you from adding placements where ads will have significant problems, such as not being clickable or viewable. However, it is ultimately the publisher’s responsibility to choose a functional ad layout, and to ensure compliance with all Google publisher policies.

Steps to manually insert placement code

This code adds an AdSense placement to your WordPress site. After you add the code, you can manage the placement with the AdSense Plugin for WordPress. Note that the ID must be unique: each time you add this snippet of code, use a different name for the ID.
<ins id="unique-ID"
style="display: none;"
class="adsbygoogle-placeholder"></ins>

1. Format your code

  • ID: Each time you add this code, use a different unique ID in place of unique-id. Use normal HTML for your ID, with no spaces. E.g., front-page-123sidebar-ad-124, bottom-ad-125, etc.
  • Preview: You can preview your insertion with our plugin, just like the rest of your placements. However, you need to take extra steps if you wish to preview your insertion outside of our plugin, such while developing your theme and CSS locally. In that case, you must change display: none to display: block in each placeholder you want to preview. Just remember to change the style back to display: none before you update the file.

2. Insert your code

There are several ways you can add this placement code to your WordPress site. Here are two examples:

3. Check your inserted placement

After you manually insert placement code, manage ads with the AdSense Plugin for WordPress to verify that your placement is now recognized by the plugin.
  • Find the marker: The plugin should show a placement marker  in the spot that corresponds to your edited PHP file.
  • Check the settings: When you open the placement settings, the plugin will indicate that the placement is defined in your HTML code
  • Resolve issues: If you inserted code in an invalid place, the plugin will show you a gray marker  in the spot where you added code for a placement. The reason is probably that an ad in this location would be unclickable, would not display correctly, or would overlap with your site content. Try inserting the code in a different location.

Help us improve this feature! We want to hear your feedback. Click here to send questions and comments.

No comments:

Post a Comment