Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #252513


    I used the theme options (Enfold / Theme Options) to add the Google Analytics code. It seems that this is placing the tracking code outside the <head></head>> tags. However, this is how Google says it should be added to make sure all data is correctly collected:

    “Paste your snippet (unaltered, in it’s entirety) into every web page you want to track. Paste it immediately before the closing </head> tag.
    If you use templates to dynamically generate pages for your site (like if you use PHP, ASP, or a similar technology), you can paste the tracking code snippet into its own file, then include it in your page header.”

    Is it possible to update the theme options to correctly place the code? For now it’s probably best to manually add it to the header.php file ?


    Hey Ville!

    Please see (Purchase code hidden if logged out) -google-analytics-code – since several years google recommends to place the code at the end of the website because of performance, etc. reasons.

    Best regards,


    Hi Peter

    Earlier it was ok to place it at the end of the page, but now it’s recommended to have it in header section. There’s a quote from the updated Google instructions behind your link, it says:

    “Paste it into your web page, just before the closing </head> tag.
    One of the main advantages of the asynchronous snippet is that you can position it at the top of the HTML document. This increases the likelihood that the tracking beacon will be sent before the user leaves the page. It is customary to place JavaScript code in the <head> section, and we recommend placing the snippet at the bottom of the <head> section for best performance”



    Thank you for the update.

    If you want the google analytics on the head section, please use this on functions.php:

    function ava_google_analytics() {
         $output = "GOOGLE ANALYTICS CODE HERE";
         echo $output;

    Remove the google analytics code on the theme options.



    Hi Ismael

    Thanks. I pasted the code straight to the header.php file, is that ok? Will it stay there if the theme is updated?



    Thank you for the update.

    I’m sorry but the code will be remove if you update the theme unless you’re using a child theme. Copy the header.php file on your child theme folder then make the changes there or you can try the wp_head hook code that we suggested above. :)


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.