Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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,
    Chris

    #164357

    ….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 :/

    #164371

    Hello!

    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: http://wordpress.org/plugins/solid-code-theme-editor/

    Best regards,
    Peter

    #164375

    cheers Peter, will give it a go :)

    #164386

    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,
    Chris

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

    • This reply was modified 11 months, 2 weeks ago by  cdapex.
    #164410

    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,
    Devin

    #164442

    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,
    Chris

    #164452

    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 .

    #164454

    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,
    Chris

    #164456

    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….

    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

    ga(‘create’, ‘UA-XXXXXXXX-1′, ‘obutto.com’);
    ga(‘send’, ‘pageview’);

    </script>

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

    <script type=”text/javascript”>

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

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

    </script>

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

    Thanks for your time!

    Best regards,
    Chris

    #164824

    Hey!

    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.

    Regards,
    Devin

    #164866

    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,
    Chris

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

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