[Resolved] Every time I update GP I lose Google Analytics and Search console html code

Home Forums Support [Resolved] Every time I update GP I lose Google Analytics and Search console html code

Home Forums Support Every time I update GP I lose Google Analytics and Search console html code

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #816711
    Nacho

    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.

    #816785
    epickenyan

    Just choose the validation option that allows you to download a file and then upload the downloaded file to your website’s root directory.

    #816789
    David
    Staff
    Customer Support

    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.

    #819060
    Nacho

    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.

    #819162
    David
    Staff
    Customer Support

    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.

    #823417
    Nacho

    Hello David,

    Thanks a lot for the information. I´ve just done and it works perfect.

    Have a nice day.

    #823443
    David
    Staff
    Customer Support

    Great to hear that 🙂

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.