Setting up a Google Merchant product feed

Google Merchant Center is a tool for promoting your products through e.g. Google Adwords campaigns and more.

To integrate with the Google Merchant Center, you must set up a Google Product Feed.

A Google Product Feed is a webpage with product data in one of the formats supported by Google Merchant Center – .xml or .txt – and formatted in the way necessary for Google to read the feed.

You can read more about the Google Merchant Center, and about data feeds specifically at the Google Merchant Center help pages.

Here’s how to set it up in Dynamicweb.

To get started with creating a Google product feed:

  • Create a new page in your content tree and name it Google Feed
  • Open the page properties
  • Uncheck all the accessibility options and set it to Hide in menu (Figure 2.1)
  • Save the page properties
Figure 2.1 Uncheck all the accessibility options and hide the page in your menu

On the new page,

  • Create a new paragraph
  • Attach a product catalogue app
  • Select the products you want to publish – all products in a shop, specific product groups, or a custom query from one of your indexes (Figure 3.1).

Save the app settings and the paragraph once you’re done.

Figure 3.1 Publish products to the feed using a product catalogue app

Since the page is an RSS feed, you need to create an RSS layout to match it.

Create an empty RssFeed.xml layout file in the designs folder for your website. It could look like the following example:

<?xml version="1.0"?> <rss version="2.0" xmlns:g="http://base.google.com/ns/1.0"> <channel id="content.main" class="dwcontent" title="Main content" data-settings="removeid:true;template:ModuleOnly.html;"> </channel> </rss>

I.e. a normal RSS feed XML document without the items and with the Google shopping namespace added.

The channel node is decorated with Dynamicweb content placeholder attributes and settings.

On the settings attribute the default app template is specified, and a new setting, removeid, is set to true. The removeid setting tells the layout parser that it should remove the ID attribute of the channel node. 

Next, you need to make the Google Feed page an RSS feed:

  • Go to the page properties of the Google Feed page
  • Go to the layout tab (Figure 5.1)
  • Select the RssFeed.xml layout in the layout dropdown
  • From the content type dropdown, select text/xml as the custom content type
Figure 5.1 Select the RssFeed.xml layout you just created and set the content type to text/xml

In the page properties > URL settings area, enter GoogleFeed.xml in the Exact URL for this page field (Figure 5.2) – Google requires the feed to be named .xml.

Figure 5.2 Create an exact URL for the feed

The page now looks like an XML file, the response content type is XML and the output has the beginning of an RSS feed.

Viewing the page in frontend, however, will still result in a browser error; the page is served as an RSS feed, but the content of the channel node (with the content placeholder dwcontent) is still HTML, since it’s based in the default product list template.

To change the module output to play nice with your RSS feed page, you need to create a couple of new templates:

  • In the Files/Templates/Designs/YourDesignName/RssFeed/Paragraph folder, create a new template and name it ModuleOnly.html. In the file, add the <!--@ParagraphModule--> tag ONLY.
    • This will make sure that only the module output is shown from the paragraph. You don’t need to apply the template to the paragraph with the product catalog attaches, as it was set as default template on the content placeholder in the RssFeed.xml layout file you created.
  • In the /Files/Templates/Designs/YourDesignName/RssFeed/eCom/ProductList folder, create a new template and name it RssProducts.html.
    • This template should contain a loop rendering your RSS feed items. You can add markup similar to Figure 6.1, but please check the current Google Merchant attribute requirements documentation to make sure you follow the guidelines appropriate for your scenario.
<title>Dynamicweb Products RSS Feed</title> <link>http://www.dynamicweb-cms.com</link> <description>A description of your content</description> <!--@LoopStart(Products)--> <item> <title><!--@Ecom:Product.Name--></title> <link>http://<!--@Global:Request.Host-->/<!--@Ecom:Product.LinkGroup.Clean.HtmlEncoded()--></link> <description><!--@If(Ecom:Product.ShortDescription<>''--><!--@Ecom:Product.ShortDescription.StripHtml().HtmlEncoded()--> <!--@Else--><!--@Ecom:Product.LongDescription.HtmlEncoded()--><!--@EndIf--></description> <g:image_link>http://<!--@Global:Request.Host--><!--@Ecom:Product.ImageSmall.Default.Clean--></g:image_link> <g:price><!--@Ecom:Product.Price--></g:price> <g:condition>new</g:condition> <g:id><!--@Ecom:Product.ID--></g:id> </item> <!--@LoopEnd(Products)-->

To use the RSSproducts.html file to publish your products to the RSS feed:

  • Go to the GoogleFeed page
  • Open the Product Catalog settings
  • In the templates section, select the RssProducts.html template as your list template (Figure 6.2)
  • Save your product catalog settings
Figure 6.2 Select your RssProducts.html templare as the product list template

And that’s it – your feed is now ready for integration with Google Merchant Center.