Archived topic
Every time I update GP I lose Google Analytics and Search console html code
6 replies · Started by Nacho on February 21, 2019
Hello Tom,
I don´t know why but every time I update Generate Press I lose the html code in the header of Google Analytics and Search Console. Why is this happening and how can I solve this for future updates?
Thanks a lot.
Just choose the validation option that allows you to download a file and then upload the downloaded file to your website's root directory.
Hi there,
if your adding scripts directly to the theme templates then these are overwritten on update. You can add them using a child theme or the simplest way is to use the GP Hook Element and hook your codes in there:
https://docs.generatepress.com/article/hooks-element-overview/
These will remain in place when the theme updates, they are also easily accessible from within the WP Dashboard.
Hello David,
And where do you put the hook? before header, after header, before header content, after header content, before logo, after logo or header?
And what about the "execute shortcode" or "execute php" options? Do I need to check those?
Thanks a lot.
Scripts for Google Analytics and Search Console need to be placed in the <head> - for this you would use the WP_Head hook
Scripts that need to be placed at the opening tag of the <body> such as the 2nd script used by Google Tag Manager would go in the before_header hook
For these scripts you do not need to check Execute Shortcodes or PHP.
Hello David,
Thanks a lot for the information. I´ve just done and it works perfect.
Have a nice day.
Great to hear that :)