Google Search Console verification in WordPress: where to paste the head code
Google Search Console verification in WordPress usually comes down to pasting a code into an SEO plugin field. Yoast SEO and Rank Math have fields for it, so you needn't edit the head. If you have access to your domain panel, a DNS record is better. Code put into a theme file disappears when the theme updates, unless it is a child theme.
Author: The TellMyShop team. A guide for WordPress site and WooCommerce store owners: the cause, the manual fix and the same work in a chat conversation.
Last updated: · 6 min read
Why Google tells you to paste code into the head
Search Console shows data about your site only to its owner. The verification code is proof that the site belongs to you. With the “HTML tag” method, Google gives you one line, a google-site-verification meta tag, which has to appear in the head section of the homepage. All the methods are described in the Search Console help on verifying ownership.
The head section is the invisible part of the page with information for browsers and search engines. In WordPress you don't edit it in the post editor. It is built by the theme together with plugins that add their own tags there. So instead of looking for a file, it is usually better to use a plugin that already does this.
Two things are worth knowing up front. A “Domain” property covers the whole domain, with and without www, but it can only be verified with a DNS record. A “URL prefix” property covers one exact address and accepts the meta tag.
Four methods side by side
| Method | Where you do it | What it survives | When to choose it |
|---|---|---|---|
| SEO plugin field | Yoast SEO or Rank Math settings | theme updates, theme changes | you have Yoast or Rank Math, it is the simplest |
| TXT record in DNS | domain or hosting panel | everything, it doesn't touch the site | you have DNS access and want a “Domain” property |
| Child theme | the child theme's functions.php file | updates of the parent theme | you have no SEO plugin and no DNS access |
| HTML file | hosting file manager or FTP, the site's root folder | theme updates, not always a move | you have FTP and don't want to touch the theme |
There is a fifth, bad route: pasting the tag into the parent theme's header.php file. It works until the first theme update. Some time later Search Console reports lost verification, and you don't connect it with the update from a week ago.
Verification with Yoast SEO or Rank Math step by step
This is the route for most WordPress sites, because an SEO plugin is usually already installed.
- In Search Console, add a “URL prefix” property. Enter the address exactly as you see it in the browser, with https and with or without www.
- Choose the “HTML tag” method and copy the code. From the whole tag you only need the string of letters and digits from the content attribute, meaning what sits in quotes after content=.
- Paste the code into the SEO plugin field. In Yoast SEO it is the site connections settings, described in Yoast's help on site connections. In Rank Math it is the general settings, webmaster tools section, described in Rank Math's guide to Google verification.
- Save the settings and clear the cache, if you use a cache plugin.
- Check the homepage in a private window. Open the page source and search for “google-site-verification”. The tag should be there.
- Go back to Search Console and click Verify.
The most common mistake is pasting the whole tag instead of just the code. The plugin then reports invalid characters or saves a code Google won't recognise.
When you have no SEO plugin: a child theme
Without an SEO plugin, the tag has to be added in the theme. You do this in the child theme's functions.php file, with a function hooked to wp_head, the place where WordPress and plugins add tags to the head section. The mechanism is described in the wp_head documentation.
Here is a trap for the owner. If the site doesn't have a child theme yet, one has to be created and activated. With classic themes, some Customizer settings are stored separately for each theme, so the look can change after switching to the child theme. This is a job for whoever looks after the site, or a reason to choose a DNS record.
You add the DNS record in your domain panel: Search Console gives you a TXT entry that you copy into the DNS zone. The change may take a while before Google sees it. In return, the code doesn't depend on WordPress, the theme or plugins.
After verification: what to leave alone
The code stays for good. Google checks it from time to time, so removing the tag, changing SEO plugin or moving to another server can cost you access to the reports. When switching from one SEO plugin to another, check that the code came across. There is more on this in the comparison Yoast or Rank Math.
After verification, submit the sitemap and inspect the homepage. We describe the steps in the guide on how to add a WordPress site to Google.
How the chat helps with the verification code
The TellMyShop plugin for WordPress and WooCommerce lets you do this in a conversation. You paste the tag from Search Console, and your chat (Claude or ChatGPT) checks whether the site runs Yoast SEO or Rank Math and suggests the simplest place for the code. After saving, it opens the homepage the way a visitor sees it and checks that the tag is in the code.
You: Google wants me to paste this code into the head: <meta name=“google-site-verification” content=“abc123xyz”>. Do it.
Your chat: The site runs Yoast SEO, so the simplest option is to enter the code in its Google verification field, without touching the theme. The field is currently empty. Preview of the change:
The Service switch is on. Shall I save it?
You: Yes.
Your chat: Saved. The google-site-verification tag is in the homepage code. Now go back to Search Console and click Verify. Don't remove the code, Google checks it from time to time.
old version: (empty)
new version: abc123xyz
The code in this conversation is illustrative.
Adding the code is technical work. In TellMyShop Pro the chat does it after you turn on the Service switch in the plugin panel. The switch lasts 3 hours and requires a database backup from today, and you always see a preview and approve the change before saving. You can undo most changes from the history. In the free TellMyShop Free the chat reviews the site's health and content and tells you where to start, but saves nothing.
What the plugin won't do: it won't create a Search Console account, click Verify or add a DNS record with your domain provider. If you prefer to do it yourself, the SEO plugin field from the instructions above will take you a few minutes. You will find the details on the TellMyShop for WordPress and WooCommerce page, prices in the pricing and more guides on the blog.
Questions and answers
Where in WordPress do I paste the Google verification code?
The simplest place is the SEO plugin's field. Yoast SEO has it in the site connections settings, and Rank Math in the general settings, in the webmaster tools section. You paste only the string from the content attribute, without the rest of the tag.
Can I remove the code after verification?
Don't remove it. Google checks from time to time that the code is still on the site, and when it disappears you lose your owner status in Search Console. You only get it back after verifying again.
Why not paste the code into the theme's header.php file?
Because a theme update overwrites that file with the author's version, and the code disappears along with your change. If the code has to go in the theme, then only in a child theme. It is simpler and safer to use the SEO plugin field or a DNS record.
Verification fails even though the code is pasted in. What should I check?
First, whether the Search Console property has exactly the same address as the site, with https and with or without www. Then clear the site cache and open the homepage source in a private window. If the tag isn't there, the site is showing an old version or you pasted the code into the wrong field.
Will TellMyShop verify the site in Search Console for me?
Not entirely. The Search Console account and clicking Verify are yours, because it is your Google account. In TellMyShop Pro the chat can add the code to the site after you turn on the Service switch and check that the tag is visible on the homepage.
WordPress is a trademark of the WordPress Foundation. WooCommerce is a trademark of Automattic Inc. Claude is a trademark of Anthropic PBC. ChatGPT and OpenAI are trademarks of OpenAI. TellMyShop is not affiliated with these companies.