> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://helpdesk.ezmob.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# 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](https://dashboard.ezmob.com).
   
   a. Log in to the [EZmob Dashboard](https://dashboard.ezmob.com).
   
   b. Select the** Sites & Placements** tab and click on **GET PLACEMENT**.
   ![](https://storage.crisp.chat/users/helpdesk/website/a54d794cc8c41800/2022-01-31-155926-window_16ws9o4.png)

   c. Click on **COPY CODE** to copy the Ad Tag to your clipboard.
   ![](https://storage.crisp.chat/users/helpdesk/website/a54d794cc8c41800/2022-01-31-160019-window_dg85ra.png)

---

### 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**
* [This free WP extension](https://wordpress.org/plugins/header-footer/) allows you to add code to the `<head>` section.

**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.
   ![](https://storage.crisp.chat/users/helpdesk/website/a54d794cc8c41800/2022-01-31-185757-window_qawdlq.png)

4. 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.
   ![](https://storage.crisp.chat/users/helpdesk/website/a54d794cc8c41800/2022-01-31-190049-window_dkudz4.png)

| **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.

2. 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.
   ![](https://storage.crisp.chat/users/helpdesk/website/a54d794cc8c41800/dobavlyaem-kod-v-head-3_1y1e062.png)

3. Add the required code **before the closing&#32;`</head>`&#32;tag**.
   ![](https://storage.crisp.chat/users/helpdesk/website/a54d794cc8c41800/dobavlyaem-kod-v-head-4_ywc3mi.png)

---

#### 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`

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

```php
   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](https://ezmob.crisp.help/en/category/monetization-e9rtp8/).

---

## Related Articles

[How to set up EZmob Header bidding banners on the WordPress platform](https://helpdesk.ezmob.com/en/article/how-to-set-up-ezmob-header-bidding-banners-on-the-wordpress-platform-ab5jxd)
[How to add an ad tag to <head> section in Blogger platform](https://helpdesk.ezmob.com/en/article/how-to-add-an-ad-tag-to-head-section-in-blogger-platform-1ucjo81)
[EZmob Publisher : Getting Started](https://helpdesk.ezmob.com/en/article/ezmob-publisher-getting-started-8gyat6)
