Categories
Digital Marketing Facebook Ads Shopify

Fix Missing Fields in Shopify’s Facebook Product Feed

Shopify’s current Facebook integration is missing some key product data. Here is how to fix your feed.

Last Update: March 29, 2021

If you use the Facebook Channel on your Shopify store, you will notice that some product attributes are missing in the product catalog:

  • Google Product Category fixed!
  • SEO Description
  • Gender
  • Material
  • Additional Images

Below is the solution to add these missing details. This will give you finer control over your Facebook Product Sets and will let you create richer dynamic ads with multiple product images.

Pre-requisites

Before we start, make sure all of the following are done:

  1. Install the Google Sales Channel
    The script leverages some of the metafields that are created on by the Google Sales Channel
  2. Install the Facebook Sales Channel
  3. Setup Empty Field Rules
    This is not actually a pre-requisite, but it’s a good backup in case things break down with your feed. This sets some default values for fields such as condition and availability.
  1. Go to Facebook Business Manager and then
    Commerce Manager > Catalog > Data Sources
  2. Click on your data feed and go to Settings
  3. Scroll down to Data Feed Rules and click on Add Rules > Set Default Values
  4. Create default values for age_group, gender, availability, condition, material, and any other fields that make sense for your business.

Step 1
Create the Facebook Product Feed Template

To create the Facebook product update feed, we will use a “hack” to transform a standard Shopify Collection page into and XML data feed:

  • In the Shopify admin, go to
    Online Store > Themes > Action > Edit Code
  • Under Templates, choose Add a new Template
  • Choose collection from the drop down and name your template facebook-feed-template

Paste the code below into your newly created template file and click Save.

{% layout none %}<?xml version="1.0"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
{%- paginate collection.products by 1000 -%}
{%- assign useSEOdescription = true -%}
{%- assign additionalImagesForVariants = false -%}
{%- assign includeOutOfStock = false -%}
{%- assign filterVariantImagesByColor = false -%}
{% comment %}
This template is used to add additional information to the Facebook product catalog
Documentation: https://business.czarto.com/2019/12/11/update-your-shopify-facebook-product-feed-with-missing-attributes/

<comment:title>{{ product.title}} {{variant.title}}</comment:title>
{% endcomment %}
<channel>
<title>{{ shop.name }} {{ collection.title | replace: '&', '&amp;' }}</title>
<link>{{ shop.url }}</link>
<description>{{ collection.description | strip_html }}</description>
{% for product in collection.products %}
{%- assign Gender = product.metafields.mm-google-shopping.gender -%}
{%- assign AgeGroup = product.metafields.mm-google-shopping.age_group -%}
{%- assign Material = product.metafields.mm-google-shopping.material  -%}
{%- assign Color = "" -%}

{%- if product.variants.size > 0 -%}
{%- for variant in product.variants -%}
{%- if includeOutOfStock or variant.available -%}
{%- for option in product.options -%}
{%- if option == 'Color' -%}{% capture Color %}{{ variant.options[forloop.index0] }}{% endcapture %}{%- endif -%}
{%- endfor -%}

{% assign additional_images = product.images %}
{% if filterVariantImagesByColor %}{% assign additional_images = product.images | where: "alt", Color | sort: 'attached_to_variant' | reverse%}{% endif %}

<item>
<g:id>{{ variant.id }}</g:id>
<g:brand>{{ product.vendor }}</g:brand>
{% if useSEOdescription and product.metafields.global.description_tag.size > 0 %}<g:description>{{ product.metafields.global.description_tag | strip_html | strip_newlines | replace: '&', '&amp;' }}</g:description>{% endif %}
<g:product_type>{{ product.type | replace: '&', '&amp;' }}</g:product_type>
<g:mpn>{{ variant.sku }}</g:mpn>
<g:item_group_id>{{ product.id }}</g:item_group_id>
<g:content_id>{{ variant.id }}</g:content_id>
<g:material>{{ Material }}</g:material>
<g:gender>{{ Gender }}</g:gender>
<g:age_group>{{ AgeGroup }}</g:age_group>
{% if additionalImagesForVariants %}
{% if additional_images.size > 1 %}{%- for image in additional_images offset:1 limit:10 -%}
<g:additional_image_link>https:{{ image.src | product_img_url: 'master' }}</g:additional_image_link>
{% endfor %}{% endif %}
{% endif %}
</item>
{%- endif -%}
{% endfor %}
{%- else -%}

<item>
<g:id>{{ product.id }}</g:id>   
<g:brand>{{ product.vendor }}</g:brand>
{% if useSEOdescription and product.metafields.global.description_tag.size > 0 %}<description>{{ product.metafields.global.description_tag | strip_html | strip_newlines | replace: '&', '&amp;' }}</description>{% endif %} 
<g:product_type>{{ product.type | replace: '&', '&amp;' }}</g:product_type>
<g:item_group_id>{{ product.id }}</g:item_group_id>
<g:material>{{ Material }}</g:material>
<g:gender>{{ Gender }}</g:gender>
<g:age_group>{{ AgeGroup }}</g:age_group>
{% if product.images.size > 1 %}{%- for image in product.images offset:1 limit:10 -%}
<g:additional_image_link>https:{{ image.src | product_img_url: 'master' }}</g:additional_image_link>
{% endfor %}{% endif %}
</item>

{% endif %}
{% endfor %}
</channel>
</rss>
{% endpaginate %}

or download from Github

Although the script above will work as is, there are three items that you can configure:

useSEOdescription = true
Setting this to true will use your product’s SEO description. Setting to false will not upload any description (default Shopify feed will be used)

additionalImagesForVariants = false
Setting this to true will upload all your product’s additional images. If you use variants, all your variants will have the identical additional images (their primary image will be as-configured in Shopify)

filterVariantImagesByColor = false
Setting this to true will only upload additional images for a variant IF the ALT text of the images exactly match that variant’s color attribute.

Step 2
Select the Products to Send to Facebook

Now select which products will be included in your feed.

  • In Shopify Admin, go to
    Products > Collections > Create Collection
  • Enter a Title: “Facebook”
  • Add Products to the collection (either manually or using conditions). If you want to include all your products, then add a rule similar to “Inventory Stock is greater than 0”.
  • IMPORTANT!
    Assign the Facebook Feed Template to this collection.
    In the bottom right column of the page, you should see a section called Theme templates. Choose collection.facebook-feed-template otherwise none of this will work.
  • At the bottom of the page, click on Edit Website SEO and enter “facebook” as your collection url handle. (optional – but helps with remembering your feed url)
  • Save and Preview the collection. You should see unformatted text on the screen. This is your Facebook feed. Do a “View Source” in your browser to preview the XML data.
  • Copy the url of this page. It should look similar to https://www.yourstore.com/collections/facebook

Step 3
Upload your Product Feed to Facebook

  • Go to your Facebook Business Manager and go to Commerce Manager
  • Expand Catalogs in the left hand menu and select Data Sources
  • Click on your data source name and then on Settings
  • Scroll to the bottom of the screen and click on Update Schedule and choose Hourly
  • Paste in the feed url generated in Step 2 and click Save
  • Click Request Update Now
  • Wait for Facebook to finish fetching your feed

Done

Your products should now have the missing information added. You will probably want to repeat STEP 3 anytime you modify or add new products to your shop.

It’s just a matter of time before Shopify starts uploading the full data specs to Facebook, but until that time, this is the workaround!

Related Reading

33 replies on “Fix Missing Fields in Shopify’s Facebook Product Feed”

Hi Alex,
Thank you very much for this helpful data.

I want to take only one variant to the feed. Is this possible? Can you help me with that?

Like

Hi Pierre,

Try changing this line:
{%- if product.variants.size > 0 -%}
To this:
{% if false %}

That *should* only generate data for the top level product, and not for any variants.

Let me know if that works.

Alex

Like

Hey Alex,

Thank you for writing this much needed guide.

I was hoping to find some clarification on Facebook dynamic pixel data. I am thinking of removing the shopify app as I would like more control over the images (they come out wrong on facebook) and instead using a spreadsheet upload.

Will this affect historical pixel data for dynamic ads meaning will previous store events be scrapped with an entirely new catalog/datasource?

Thank you in advance.

Like

Hi Alex,
I also want to add FB category IDs I think FB Category ID is also a missing field on Shopify correct me if I’m wrong. Do we need to add the same as Google Category IDs? But the question is where the FB Category ID information will come from?

Like

Hi Alper,

My understanding is that Facebook will use the Google Product Category if the FB Category is missing, and that only one is needed. Using the Google Product Category is the simplest route as Shopify already has ways of setting this (via the Google Shopping Sales Channel).

So I *believe* FB Category Id is not needed.

Alex

Like

Hi again,
As far as I know, the FB algorithm is using this category ID (when you’re using a dynamic catalog on the ad section) to match people who engaged to this category ID before. That’s why I think it’s also necessary to help the FB algorithm to get better results.

Like

Oh actually, I have fixed it! But, now all of my products were rejected for not having a price, description, title, image link, condition, link. But, they all do have those?

Like

Do you have your Facebook Sales Channel connected in Shopify, and all products uploaded via that? The feed you’re building in this tutorial is a supplemental feed that enhances what is already there (it won’t work unless the other feed is there)?

Like

Hi Shelly — Do you know WHY you have multiple feeds? If there’s no good reason for multiple feeds, then they might just be leftovers from some previous attempts at getting things up and running. One option is to delete them all, and then re-connect the Facebook Sales Channel in Shopify.

Like

Is there anyone that I can hire to help me with this? I’m in a never-ending loop between Facebook and Shopify and my Ad agency who all claim it’s the other guys problem. I requested a professional on Storetasker as well and no takers for this issue. I can’t move forward until it’s fixed.

Like

Hello, do I keep the original html in the collection template, or do I remove that before pasting the html? thanks!

Like

Thank you. I had such a hard time getting shopify to talk to Facebook to talk to Instagram that in the end I just kept shopify and instagram separate and gave up on Facebook commerce.

Like

Hey Alex,

Followed the guide to the T, seemed to work great. though the only error i ran into was with the ‘link’

Error Message:
A required field is missing: link
Products without “link” information can’t be uploaded. Please check that this field is included for each product in a separate, labeled column.

As far as i can tell, a link is present. Maybe its not recognised? any ideas?

Cheers!
James

Like

Hey Alex, ran into an issue with products being rejected because of the ‘link

Error message: A required field is missing: link

Products without “link” information can’t be uploaded. Please check that this field is included for each product in a separate, labeled column.

As far as i can tell there are links present, but not being recognized maybe? any ideas?

Like

Hi James — Just a guess, but it might because your main Shopify feed is uploading a subset of all your products, while the supplementary feed is uploading all the products, and so some products that are in the supplementary feed but not in the main feed don’t have all the required attributes.

Does that make sense in your situation?

Best,
Alex

Like

Thanks for the response! really struggling with this one.

I think i’m following what you explained, although i tried deleting the main Shopify feed, so that there wouldn’t be any conflict. Same issue still shows. Link not been recognized, even though there are links present in the issue report

Like

Actually, you should leave the main shopify feed.

the fix would be to one of:
1) Make sure the supplemental feed only contains the products in the main feed
2) Make sure your main feed contains ALL products, and then mark some of them as inactive in Facebook if you don’t want them to show up there.
3) Just ignore the error. I don’t think it should hurt anything.

Longer term, at some point I will update the feed so that it only includes products that are live in the Facebook Sales channel.

Like

Hmm… with the links not being recognised and facebook showing them as missing, no products are being shown right now.

Appreciate your help.

Like

Hello,
I did everything you said to do in the post and I am getting an error message when I upload the url to my data source and click “Request Update Now”. The message reads:” HTML format isn’t supported
Please check that your file is in the correct format. Supported file formats include CSV, TSV or RSS/ATOM XML.”

Any idea on how I can fix this?

Thank you,
Angelina

Like

Hi Angelina,

I took a look at your feed file and everything seems correct. Usually the HTML error is when the collection template isn’t set to the XML feed template, but yours seems to be set correctly.

Are you receiving a line number with the error?

Like

Hello,

I have same issue with Angelina.

HTML format isn’t supported:
Please check that your file is in the correct format. Supported file formats include CSV, TSV or RSS/ATOM XML.
1 product was rejected
No preview available for this issue

Can you help me to fix it? I don’t know where should I ask it to.

Like

Hi Jisun Chung,

The issue is usually that you didn’t select the correct collection template.
Make sure you completed the first bullet point in Step 2.
Make sure when you preview your collection you are only seeing unformatted text, and no images.

Hope this helps.

Alex

Like

This post is a life saver!! You would think Shopify would have implemented this on their end by now.

For the subtype Beauty, how would I include the recommended data: capacity (0.25oz) and ingredients (multiple items)?

Like

Hi Roman,

For the feed itself you would probably need to include something along the lines of:

<capacity>{{ capacity_metafield }}</capacity>
<ingredients>{{ ingredients_metafield }}</ingredients>

You would likely need to store those values in Shopify metafields for each product.

Alex

Like

I still use your original manual feed implementation, which seems to work better than the newly implemented Shopify one, partly because we can have ownership of our catalogue rather than the owner being specified as Shopify.

With that said, I am having an issue with our feed not sending the right content_ids to Facebook. Instead, it sends the the product group ID. This essentially stops the dynamic ads from serving all together. I am trying to modify the above to see if i can make sure the correct content_IDs gets sent through.

Like

Hi Akin,

I had similar issues, and never quite figured out how to resolve them. At the time (still?) there wasn’t much documentation available around Shopify’s Facebook pixel implementation with regards to remarketing.

From Facebook’s side there is “Group Id” and “Content Id”, while on Shopify’s side there’s Variant Id or Product Id. As you mentioned, Shopify seems to pass the Shopify Product Id in the Facebook Group Id variable — I unfortunately haven’t looked deeply at either side’s implementation to be able to help with this, but please let me know if you find a solution (If I figure something out, I will post it here as well).

Best,
Alex

Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s