Site logo

Archived topic

HTML Tag removed from Theme Header (Google Analytics and Google webmaster)

5 replies · Started by kyle on November 5, 2020

Viewing posts 1–6 of 6

Hi there, I have no idea why, but my HTML tag for google webmaster tools and google analytics was removed from my theme header? How is this possible???

Hi there,

how was the code added to your site ?

It was added through the theme editor and has been active for about 8 months. And all of a sudden disappeared.

You should never make direct edits to the parent Theme files as they will be lost when the theme is updated. Changes to theme code should only be done with a Child Theme.

However, for adding GT / GTM codes to the site - this guide explains how to do that with hooks.

https://docs.generatepress.com/article/implement-google-tag-manager/

Simple rule with Hooks for adding code - you can use these hooks:

wp_head - for code inside the <head></head>
wp_body_open - for code immediately after the opening <body> tag
wp_footer - for code in the footer before the closing </body> tag

Using the Hook method will not be affected by Theme updates.

Thankyou that worked, i got a firght and thought all my data was lost!

Glad to be of help!

This archived topic is closed to new replies.