How to implement ad tags into WordPress

Header code and ad tags are key tools for embedding particular ads into websites, especially when working with certain ad networks or techniques.

This tutorial explains how to use the free Advanced Ads plugin for WordPress to implement ad tags effectively, including tips for integrating Google Ad Manager ads.

Introduction to ad tags

Ad tags are snippets of code publishers insert into their websites to show advertisements. These tags communicate with ad servers to request and display the appropriate ads. 

Here is an example of an asynchronous ad tag to embed Google AdSense Auto ads:

<script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>

For a more detailed explanation, including the distinction between synchronous and asynchronous ad tags, check out our comprehensive guide to ad tags.

Implementing ad tags with Advanced Ads

To implement ad tags with Advanced Ads, install and activate the free plugin from the WordPress repository. Once it’s set up, create an ad unit.

  1. Go to Advanced Ads > Ads > New Ad
  2. Choose “Plain Text and Code” as the ad type
  3. Paste your ad tag into the code field
  4. Publish the ad
media.net header tag
Example of a synchronous media.net ad tag in a new ad unit of Advanced Ads

Next, link the ad unit to a placement. Go to Advanced Ads > Placements > Add New Placement, select the Header (/head) placement option, and assign the ad unit you created in the previous step. 

Creating a new header placement in Advanced Ads
Create a header placement in Advanced Ads by selecting the placement option with the icon

Save the placement, and Advanced Ads will automatically insert the ad tag into the <head> section of every page on your website.

For precise targeting, you can refine the insertion of the ad tag by configuring Display and Visitor Conditions. This optional configuration allows you to restrict the tag to specific pages, content, categories, or audiences, ensuring it appears only where it is most relevant.

media.net header code
Example of a header placement with a media.net ad tag

Embedding multiple ad tags to the header

If you need to insert multiple ad tags into the header using Advanced Ads, you have two options. Each approach has pros and cons, so it is recommended that you choose the best method that suits your requirements.

Option 1: Adding all ad tags in a single ad unit

The quickest way to insert multiple ad tags is by adding all of them into the code field of a single ad unit. 

Here’s how:

  1. Create a new ad unit by navigating to Advanced Ads > Ads > New Ad
  2. Choose “Plain Text and Code” as the ad type
  3. Paste all the ad tags you want to load into the code field, one after the other
  4. Save and assign this ad unit to a Header (/head) placement

While this approach is simple and fast, it has a significant drawback. You can no longer target individual ad tags with separate Display or Visitor Conditions. This limitation can be problematic if you want precise control over where and when each ad tag is displayed.

Option 2: Using an ad group to manage ad tags individually

For better flexibility and targeting, consider creating and grouping separate ad units for each ad tag. 

Go to Advanced Ads > Ads > New Ad, and create an individual ad unit for each ad tag. Select “Plain Text and Code” as the ad type, paste a single ad tag into the code field, and save the unit. Repeat this process for all the ad tags you want to include.

Once all the ad units are ready, go to Advanced Ads > Groups & Rotations and create a new group. Add the individual ad units to this group and configure it to simultaneously deliver all ads it contains by setting the option “Visible Ads” to your total number of ad units. Save the group, then assign it to a Header (/head) placement via Advanced Ads > Placements > Add New Placement.

Example of a placement for Google Ad Manager header tags
Example of a placement for multiple ad tags

This method provides more control because you manage each ad tag as an individual ad unit. You can apply unique Display or Visitor Conditions to each ad tag, ensuring they are displayed only on the pages or the audiences you choose.

By using a group, you also maintain flexibility for future adjustments. For example, you can easily add or remove ad tags without modifying a single ad unit that contains all the code.

Integrating ad tags from Google Ad Manager into WordPress

Implementing Google Ad Manager (GAM) ads can be complex because it involves inserting two pieces of code. You need to inject one snippet into your website’s header and another in the position where the ad should later appear on the page.

The Google Ad Manager integration add-on for Advanced Ads simplifies this process. It handles the implementation automatically, eliminating the need to match codes manually across different positions on your website. 

The add-on lets you import existing ad units directly from your Google Ad Manager account. Afterward, you can assign these units to your placements for auto-injection. Advanced Ads handles the correct implementation, making the process seamless and error-free.

Author image Joachim

Joachim started marketing his first local news website in 2009. Shortly after, he successfully monetized his travel blogs about Morocco. He is an expert in affiliate marketing in the tourism and travel industry. When he's not writing tutorials for Advanced Ads or supporting other users, he prefers staying in Marrakech or at the Baltic Sea.

With over a decade of industry expertise, Advanced Ads is your surefooted ally in the ad tech realm. Their array of WordPress ad manager plugins enhances your advertising strategy, ensuring effective ad placements. Rely on their ad tech proficiency to stay ahead in the dynamic world of digital advertising. Contact info

Advanced Ads icon

Make it better

Increase your ad management skills without spending more time.
Join over 150,000 publishers and AdOpts increasing their ad revenue.