Adding google-site-verification to a Dynamicweb solution

If you own a Dynamicweb website or you are a partner supporting a customer who have build their website using Dynamicweb CMS you will gain access to a lot of cool optimizing tools on Google Webmaster tools site.

Verification required by Google Webmaster tools.
In this post I will show you how to add a Dynamicweb website item which will be used to do the Meta tag based verification of your website. A pattern which also is great for implementing website settings in Dynamicweb CMS.

Meta tag based verification

Google allows you different ways of verifying your ownership of a website. One way is to add a html meta tag to the head section:


I will not dive into the way you get this tag, simply follow the steps on Google Webmaster tools site, selecting Alternative methods and “html-tag”.

The template challenge (on multi language sites)

Dynamicweb CMS is based on templates rendering dynamic content. These templates should include the Google-site-verification meta tag (GSV), however it is commonly used to reuse the template (master template) which holds the head section, but the GSV is unique for each domain. You need to be able to add unique GSV tag based on which domain the master template is used on.

Many patterns will solve the task, however I find the solution where the user can control content best, it will work like this:

  • We create a Dynamicweb website item
  • The item will hold settings for the website – here the GSV
  • The global master page will be extended with a tag rendering the GSV

This approach has the advantage that any website google site verification can be entered in the Dynamicweb backend (by the customer). Also should the website be extended with another language, it is easy to add google site verification to the new site, without needing to alter the templates.

Why not simply add the GSV tag in a static manner?

I admit that you could argue that this task will not be required dynamic content, and therefore could be implemented in a more static pattern by inserting the GSV in the master page. However this pattern supports also future website settings, and also it is a pattern which can be easily reused on future websites.

Creating the website item

In the Dynamicweb “Management Center > Item Types” choose “New item type”. Name the item as you like, I choose to name it “Website settings“ as I expect it to be extended with further fields in future.

You should choose “Website- and page properties” for the “Enable item type for”. That will allow this item type to extend both pages and websites – in practice this it the trick which allows us to extend the Dynamicweb website and page types. For the user the settings will seem as a part of the standard Dynamicweb CMS.

You should also add a description, as it is good practice to tell the user how and how not to mess around with this value.

Add a field for the Google site verification value

Now you need to add the actual GSV field. Click new field and enter something like this:

Note that here I actually stress that the user should not alter this value. Of cause if you are a webmaster (and not an editor) you know what to do, and can alter the value if appropriate…

Alter the group name to “Custom settings”

I suggest that you alter the Group name for the fields of your website item. The item will be merged into the Dynamicweb standard website settings, and just to support the state of the new website settings as a non-standard group, and to be able to inform the customer where to find this setting, I find it a good service to name it with something with meaning.


Edit restrictions to allow the use of this item

To be able to use this item you first need to click the “Restrictions” and allow the item on the appropriate websites. In my case it is “Allow in all websites”.
— Save and the item is ready to use!

Adding the GSV website item to a website

We now need to extend the website with this GSV website item. In the navigation at the top where you see the website selector, right click and choose “Edit”. You get the website settings, and the top right you see the “Item types”, click on it:

Choose the website item you have just created, and we are ready to add Google Site verifications values to our websites.

Where can I see the new website setting?

The website item will appear on the “Edit website” page. That is the place where you add website scope settings like domain names, 404 page and Ecommerce settings. Open it by clicking “Edit” and in bottom you should see a group containing a text field where you can paste the GSV value.

Pulling out the value in your master templates – the tags

The data is now there, ready to pull out in the HTML. You will need to add the tag to the HEAD section of your Master template. The tag will be something like this (depending how you named the group and item name):


So all you need is to add the GSV tag replacing the content attribute with the dynamicweb content – the above tag. So my final change to the Master template will be:


You may want to wrap the tag into an if defined test like this:

<!--@If Defined(Item.Area.Google_Site_Verification)-->


We are done!

That was it – we have extended a Dynamicweb website to include a field to hold the Google site verification code. We have seen which tag to use, and the pattern can be used for other website and page settings. Things like Google Analytics code become editor friendly content. Happy coding!

Related information


Leave a Reply