September 21, 2013 at 8:03 am #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!
ChrisSeptember 21, 2013 at 8:48 am #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 :/September 21, 2013 at 9:35 am #164371
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/
PeterSeptember 21, 2013 at 9:54 am #164375September 21, 2013 at 11:39 am #164386
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.
*EDIT* or should the snippet be placed in the body on the header.php?
September 21, 2013 at 12:29 pm #164410
- This reply was modified 1 year, 10 months ago by cdapex.
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.
DevinSeptember 21, 2013 at 2:46 pm #164442
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.
ChrisSeptember 21, 2013 at 3:22 pm #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 .September 21, 2013 at 3:35 pm #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!
ChrisSeptember 21, 2013 at 3:41 pm #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….
ga(‘create’, ‘UA-XXXXXXXX-1′, ‘obutto.com’);
whereas this is what I see on Google’s help pages
var _gaq = _gaq || ;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js';
var s = document.getElementsByTagName(‘script’); s.parentNode.insertBefore(ga, s);
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!
ChrisSeptember 22, 2013 at 5:19 pm #164824
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.
DevinSeptember 22, 2013 at 8:04 pm #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!
The topic ‘Cannot access Editor’ is closed to new replies.