Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
  • #164350

    I’m trying to add my Google Analytics Code to the header, and from my search I found I just need to edit header.php. When I click Appearance > Editor I get the below error message…

    “Sorry, can’t edit files with “..” in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in”

    Apparently I’m doing something wrong, so please advise how to open the header.php file to edit it…..thanks!

    Best regards,


    ….or should I just edit the header.php via ftp?

    Sorry I’m such a noob at this, but I don’t wanna jack my site all up….already done that once :/



    Yes, I’d recommend to edit the file with a proper text editor and to use ftp to download/upload the file (it can be found in the wp-content/themes/enfold/ directory). You can also try an advanced theme editor plugin like:

    Best regards,


    cheers Peter, will give it a go :)


    Hey Peter,

    I used UltraEdit, man what a difference from Notepad.

    Anyhow, I pasted the google analytics snippet just before the closing </head> tag, per Google’s instructions. Well it’s not exactly before because on the Enfold theme there is a note to leave “wp_head()” just before the closing </head> tag, so I put the snippet just above that note’s <?php

    Still not able to verify the site though. Any assistance is appreciated.

    Best regards,

    *EDIT* or should the snippet be placed in the body on the header.php?

    • This reply was modified 4 years, 1 month ago by  cdapex.

    Hi Chris!

    Any reason why you aren’t using the themes Google analaytics field in the main theme options? Any code you put there gets automatically added to the wp_head output which is the “proper” way to add content to the header of your site.

    Best regards,


    Hey Devin,

    Thanks for replying, but when I put it into the theme’s field it apparently places it in the footer, whereas Google Analytics says it needs to be in the header….or I’m mistaken, but every time I try to verify, even when I use the theme’s field, it says it’s in the wrong place.

    Sorry again for my noobish’ness.

    Best regards,


    The placement doesn’t really matter as long as its on the page. Most prefer it in the footer since it then detects users who do a full page load and it keeps the initial load of the page a bit smaller.

    Just make sure you are putting in that entire block of code and not just the number .


    Rgr, so as long as I put it anywhere within the code on the “header.php” file I should be good? I’ll give the body a go and see what happens….thanks man!

    Best regards,


    ok placing the snippet in the Body of the header.php didn’t seem to work either. One thing i noticed is my snippet looks different than any sample I’ve seen on Google’s help pages, see below….

    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

    ga(‘create’, ‘UA-XXXXXXXX-1’, ‘’);
    ga(‘send’, ‘pageview’);


    whereas this is what I see on Google’s help pages

    <script type=”text/javascript”>

    var _gaq = _gaq || [];
    _gaq.push([‘_setAccount’, ‘UA-XXXXX-Y’]);

    (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);


    while I don’t understand 99.99% of all of this… obviously looks different. Sorry if this isn’t something you guys can help with, but hope it is :)

    Thanks for your time!

    Best regards,



    Here is the thing, if you are manually adding this to your header then you will need to do it every time you update the theme (since the theme will overwrite the file).

    If you don’t want to use the theme’s field then I would suggest using a plugin that lets you choose where the code gets added in. Once it is added in you just need to view the source of your page and if you see it then its up to google to register it.

    As for your code, it looks incorrect on my end but I’m not really an authority on analytics.



    Hey Devin, for some reason the Google webmaster tools still would never verify. Anyhow, I just ended up leaving the Tracking Code in the stock Enfold location, and then just uploaded an html file via ftp to the root on my server.

    All good now, and thanks for your help!

    Best regards,

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

The topic ‘Cannot access Editor’ is closed to new replies.