Search code examples
wordpressgoogle-analyticsheaderanalytics

Wordpress Analytics snippet in header


I have integrated my google analytics snippet in my wordpress CMS for quite some time with a plugin.

A content supplier then asked me to insert the snippet in the header and not in the body or footer area. So I inserted the snippet through header.php in the head area of the following self hosted Wordpress photography site.

What happens now, is that the snippet gets thrown out every now and then (about every 4 to 6 weeks) and I have no idea what update routine / plugin or what so ever is editing the header.php file. Any ideas?

Which components of Wordpress CMS write the header.php or who could I insert the snippet in a way, that it does not get thrown out?

Many thanks!


Solution

  • This could be due to Wordpress automatically updating the installed theme files through a hosting or initial Wordpress installation set up. In other words, you or your developer has instructed Wordpress to update itself, hence overwriting existing files.

    To confirm this look inside your wp-config.php file located in the root or public_html, check if the following line is set to true like:

    add_filter( 'auto_update_theme', '__return_true' );

    Just add this line To the wp-configure.php file to disable all the updates

    define( 'AUTOMATIC_UPDATER_DISABLED', true );

    That will solve the issue