4

I maintain a large number of Magento installations. I tend to find Google verification scripts littered across many production servers and many times the file is created directly on the box, failing to make it into source control, e.g.:

google950c6bee82c9eed7.html

I'm aware of the other ways of verification including meta tags, DNS records. I would be open to any suggestions that detail how you work with site verifications in your production environments.

I'm also curious if anyone has written up a blog or found some explanation of best-practices with regard to maintaining multiple verifications over time which, though I use Google in my example, obviously apply to more than just Google.

philwinkle
  • 35,751
  • 5
  • 91
  • 145
  • Am I right in stating those files only need to be there for the initial verification of google. Once done, they could actually be deleted. Not tested, but I am sure that is the case. Thus a process could be to create, verify, and delete (or a scheduled task on the box can grep for and clean them out periodically) – ProxiBlue Sep 03 '13 at 23:05
  • @ProxiBlue - I thought that too, but this -> http://stackoverflow.com/questions/15837199/is-it-ok-to-remove-google-txt-verification-records-after-ive-authorized-my-doma would suggest otherwise (and I have had to periodically had to revalidate and just did it without thinking about it too much) – McNab Sep 03 '13 at 23:08
  • In Magento's case, I suppose an admin section that displayed commonly known verification files that are loaded for that store would be handy. Seems pretty niche, but if you were to include other script based additions (with unique API credentials, that sort of thing) into one area, that would be incredibly helpful when you're jumping back and forth between a handful of sites each day and can't always remember which version of jQuery is there, and which version of JWPlayer is there, etc... – pspahn Sep 03 '13 at 23:51
  • I considered just adding in the meta tag under "Misc Header Scripts" but wasn't sure and too lazy to look into it further. Was curious what other devs do. If you remove the verification files, especially for adwords and some affiliate networks, you need to replace and re-verify. – philwinkle Sep 04 '13 at 00:12
  • I use/prefer DNS verification, so not run into this issue. Then again, later DNS entries ned to be cleared / managed, but since I am a dev, not been my problem ;) – ProxiBlue Sep 04 '13 at 02:40
  • In my case I don't manage DNS or have access for many upper-echelon (F500) customers, etc. Though I agree this is probably the preferred method esp for those on clustered apache setups. – philwinkle Sep 04 '13 at 02:44
  • @philwinkle: Been giving this some thought, and maybe the following idea could work: Create a rewrite rule in .htaccess to detect requests for files of format googleXXXXX.html, and redirect those to a controller/action. The action can then pickup the requested file, and output the correct result. This then would allow an admin area management grid to place the verification strings. (wish I had the time to implement) – ProxiBlue Sep 06 '13 at 01:26

3 Answers3

5

After much thought and research I've settled on the meta tag in System > Config > Design > Miscellaneous Head Scripts method for the following reasons:

  • It allows me to set a new verification for multiple websites, even by store view (handy for subdomained translations, e.g. en.mystore.com)
  • Prevents files from being created on a production site, omitted from source control, only to lose the on a switch/tag/update/backup/restore later on.
  • It's editible via the CMS, instantly available on all web servers even in a load-balanced situation

The final result:

enter image description here

And how it outputs in source:

enter image description here

philwinkle
  • 35,751
  • 5
  • 91
  • 145
  • A client asked us to put the verification code in only the homepage of their website. Do you know if it matter if it's on every page or just on the homepage? Here (https://support.google.com/webmasters/answer/35179?hl=en), it does say "add to your homepage." – laketuna Nov 02 '13 at 00:48
  • 1
    It doesn't matter if it's on every page - but it definitely needs to be on the index page. – philwinkle Nov 02 '13 at 00:57
1

Another way is to firstly set up google analytics on the site :

System -> Configuration -> Sales -> Google API

and then verify webmaster tools via analytics, no exta code needed.

garym66
  • 11
  • 3
  • I like this approach now, but 3 years ago this wasn't available. – philwinkle May 19 '16 at 12:31
  • Ah, good point! Don't suppose you know where else the home page title can be cahnged if the home page isn't in CMS->Pages and changing the default title in HTML Head doesn't work ? – garym66 May 25 '16 at 10:40
0

For Magento 2

Go to: Content -> Design -> Configuration -> EditTheme -> HTML Head -> Default Meta Description. Then add you Html verification.

enter image description here

Also add html verification file to your magento root folder.

enter image description here

Muhammad Ahmed
  • 411
  • 3
  • 20