Facebook Business Catalog and Google Merchant feed from Laravel
Market context
At a time when online sales already represent around 20% of total retail, entering (or scaling in) this channel is essential. But it’s not as simple as launching a shop and waiting for sales. Competition is fierce, so you need a well‑planned digital marketing strategy—usually with the help of a specialised agency.
When launching campaigns we often rely on the biggest advertising and product platforms — exactly the ones we’ll cover in this article.
How should I import my products?
To import our catalogue we must generate an XML file describing each product (title, description, link, image link, brand, price, etc.). Each attribute is enclosed in specific XML tags we’ll define below. One key element is the <g:google_product_category> tag, which must match one of the predefined platform categories. You can review the category taxonomy at this link.
Choosing the most appropriate category helps discovery and ad delivery. If there’s no perfect match, pick the closest generic category.
Below is an example XML feed for Facebook (Facebook Business):
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>Mi Tienda</title>
<link>https://mitienda.es</link>
<description>An example item from the feed</description>
<item>
<g:id>3</g:id>
<g:title>Cool Hoodie</g:title>
<g:description>Fabricada 50% algodón/ 50% poliéster de 280gr./m2.</g:description>
<g:link>https://mitienda.es/Hoodie</g:link>
<g:image_link>https://mitienda.es/Hoodie.jpg</g:image_link>
<g:brand>Mi Tienda</g:brand>
<g:condition>new</g:condition>
<g:availability>in stock</g:availability>
<g:price>42.35 EUR</g:price>
<g:size>L, XL, XXL</g:size>
<g:google_product_category>203</g:google_product_category>
</item>
</channel>
</rss>
Key tags: product & image links, price, sizes and of course the category.
Now the example for Google Merchant:
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>Mi Tienda</title>
<link>https://mitienda.es</link>
<description>An example item from the feed</description>
<item>
<g:id>3</g:id>
<g:title>Cool Hoodie</g:title>
<g:description>Fabricada 50% algodón/ 50% poliéster de 280gr./m2.</g:description>
<g:link>https://mitienda.es/Hoodie</g:link>
<g:image_link>https://mitienda.es/Hoodie.jpg</g:image_link>
<g:brand>Mi Tienda</g:brand>
<g:condition>new</g:condition>
<g:availability>in stock</g:availability>
<g:price>42.35 EUR</g:price>
<g:size>L, XL, XXL</g:size>
<g:adult>no</g:adult>
<g:google_product_category>203</g:google_product_category>
</item>
</channel>
</rss>
Only one difference: the <g:adult> tag, which is mandatory for Google.
Generating the feed on each platform
Depending on the technology stack your shop uses, catalogue generation differs. For e‑commerce platforms like Prestashop or WooCommerce you typically install a module / plugin. In our case (custom projects with Laravel) we program the XML response directly.
Building the feed in Laravel
We define a route which, based on platform and language, fetches the required product fields. Then we compose the XML string (sanitising disallowed characters in XML like <, >, &, '). Finally, we return an HTTP response with the string and Content-Type: text/xml.