Articles on: Publishers

How to add an Ad Tag to <head> section in WordPress

How to Add an Ad Tag to the <head> Section in WordPress


Adding an Ad Tag to the <head> section of your WordPress site is crucial for optimizing ad placements and enhancing monetization. This step-by-step guide will walk you through the process, ensuring you can do it effortlessly.



TL;DR

To add an Ad Tag to your WordPress site, request the tag from your Account Manager and choose one of three methods: using a plugin, editing a theme template, or utilizing a WP hook.



Step 1: Request Your Ad Tag


  1. Request an Ad Tag from your Account Manager or obtain it from the EZmob Dashboard.

a. Log in to the EZmob Dashboard.

b. Select the Placements tab and click on GET PLACEMENT.


c. Click on COPY CODE to copy the Ad Tag to your clipboard.



Step 2: Choose Your Method of Insertion


You have three options for adding the Ad Tag to the <head> section of your WordPress site:


  • Use a Plugin
  • Edit a Theme Template
  • Use a WP Hook


Select the method that you find most comfortable. Below, we will describe each option in detail.



Method 1: Use a Plugin


For beginners, using a plugin is the easiest and most recommended method.


Head, Footer and Post Injections


Steps to Follow:


  1. Install the Plugin from the WordPress plugin repository.
  2. After activation, navigate to Settings > Header and Footer in the admin panel.
  3. Go to the Head and Footer tab.


  1. In the <HEAD> section injection block, you will find two text fields:
  • The first field applies the code to all pages of the site.
  • The second field adds code only to the main page of the WP site.


Helpful Tip: Be sure to click the Save button for your changes to take effect.



Method 2: Edit a Theme Template


If you prefer not to install additional plugins, you can manually add the code to the desired template of your WordPress theme.


Steps to Follow:


  1. Navigate to the wp-content/themes directory and locate the header.php file.

Warning: It is not recommended to modify the parent WordPress theme files. Use a child theme to make edits without losing them during updates.


  1. The contents of the header.php file may vary by theme, but the main blocks are similar. For example, in the standard Twenty Twenty WP theme, you will find the <head>…</head> block at the beginning of the file.


  1. Add the required code before the closing </head> tag.



Method 3: Use WP Hook


WordPress provides a special hook that allows you to add code to the <head> section.


Steps to Follow:


  1. Open the functions.php file, which is located in the root of your theme's folder. For example, for the Twenty Twenty theme, it is located at:


/wp-content/themes/twentytwenty/functions.php


  1. To add an Ad Tag to the site header, paste the following code at the end of this file:


   function wpplus_insert_header() {
?>
<!-- An Ad Tag -->
<?php
}
add_action( 'wp_head', 'wpplus_insert_header' );


Replace <!-- An Ad Tag --> with the Ad Tag you copied in Step 1.



Conclusion


Choose the method that best suits your needs—whether it's using a plugin or editing the theme manually—and start optimizing your earnings with EZmob monetization solutions.



#




Updated on: 04/11/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!