DIY Facebook Product Feed for Shopify [deprecated]

Deprecated!

I am no longer updating / maintaining this code. Use at your own risk!

UPDATE Oct 10, 2019: I have switched to using the Shopify Facebook Marketing App (but not the Shopify Facebook Sales Channel which should be avoided) to sync my product catalogs with Facebook. Although not perfect, it does the job well enough!

UPDATE Dec 11, 2019: Shopify Facebook Marketing App does not upload all product attributes (Product Type is missing as of this writing). If you need these missing attributes, I have documented a way to upload the missing data via a custom xml feed.

Below is a free customizable DIY solution to create a Facebook Product Feed in Shopify.

This is an advanced topic and assumes you have the required understanding of HTML/XML/Liquid, the Shopify Store Admin and Facebook Business Manager.

4. Upload your Feed to Facebook

Enter the feed collection url you copied in step 3 above. Leave the username & password blank. Choose a time for your daily upload to occur (early morning is usually a good time). Choose your currency.

Click Start Upload and wait for the feed to be fetched and processed.

Fix errors: If there are errors, go back, fix them, re-fetch, and keep doing so until the feed is error free. Sometimes it is necessary to delete and re-create your catalog in Facebook for some changes to appear.

5. Prevent the Facebook Feed from Showing on your Store

Depending on how your store is setup, you may need to add some code to prevent your Facebook feed collection from showing up on your store. The exact way to do this may depend on your theme, but generally you will want to have an “unless” statement within the loop that displays your collections:

57 Comments

Hi Alex! When you say “The instructions and code below are no longer supported!” does it mean that the code doesn’t work anymore? We have a special case where our shop is multilingual and our products have both language like that: “frech title || english title”. We used your google product feed and customized it to create a feed for both language and it worked perfectly. So I’m wondering if this one is still good to start with for our facebook product feed?

Also, the code for the facebook feed and google feed seems pretty similar, do you know if we could use the same feed for both google and facebook or if that would break something?

The main difference between the Facebook and Google templates are how the product Ids are formatted. Shopify tends to use the following format for product Id’s on Google: Shopify_US_{{ product.id}}_{variant.id}}; while on Facebook they only use the product.id or variant.id. Using the same feed for both would cause any built-in dynamic remarketing tags to stop working. **BUT** if you are not using Shopify’s Google Shopping app anyway, then you theoretically *should* be able to use the Facebook version of the feed to upload your products to Merchant center…

Thank you for the information, this will be useful! And thanks a lot for providing this piece of code, I still have to make some modifications to make it work for our use case but it’s making my life a little easier!

Hi Anthony — My *guess* would be that it’s a product title or description that has a special character that isn’t allowed in XML. Best way to solve this, if you have a line number for the error, is to access the feed link in your web browser, do a view source, and go to the error line and see if there are any special characters there. Then it would be a case of either removing that character from the description or adding an extra Replace statement in the liquid.

So close…..Looks like I missed one step- the URL I pasted per step 4 generated this error message:
No products were uploaded because of the following errors:
HTML format isn’t supported
(1 product rejected)
Please check that your file is in the correct format. Supported file formats include CSV, TSV or RSS/ATOM XML.

If you visit the feed https://beadbingesupply.com/collections/facebook-product-feed you get a list of tags, with links, followed by a “filter” drop down list, etc… You likely edited the collection SECTION instead of your collection TEMPLATE. You collection template must only contain the code listed in the article, and nothing more.

(FYI: It appears that the Facebook Marketing App by Shopify (not to be confused with the Facebook Channel) now does the feed thing quite well. I recommend you give it a try instead of the method described here).

HI Alex, First of all thank you sooooo much for this post ! Best Fix iv’e saw so far! But when i do step # 4 Upload your Feed to Facebook, my catalog turn up empty 😦 I did all the step, double check everything and still no product….

I see maybe some possibility…
-Some of my product is being refused by google merchant for ivalid bar code ( but not all of them ) Does configuring the product properties: Age Group, Gender, and Product Category. for all product on my store is mandatory ?

-Created the feed and collection wrong… But the collection appears to be showing just fine when i preview and save.

RE: Required Product Properties
This depends on the type of products you have. For clothing or footwear, I believe Age Group, Gender, and Size are required. Product Category is either required or highly recommended, as it tells google what type of product you are actually selling.

Thanks for the reply.
When I open my feed URL I see: White background page with Collection Title, product image, and info ( each of them ) & bellow all item in text format with all URL and items info in a” single long sentence/paragraph format. url the shot url if you wanna take a look: https://bit.ly/2OECvLY

Thanks for the feedback but yes i correctly selected the collection template i just created i made sure to follow every step.

When i upload the feed to FB i get this error msg :
No products were uploaded because of the following errors:
Unsupported file format
(1 product rejected)
Make sure your file is in a supported format (ex: CSV, TSV, XML or ATOM) and that the first line has valid column labels (ex: title, description, price).

I saw in my code that there is a {% section ‘collection-template’ %} in the beginning of the code when i create a template. I try it with and without it and still the same error put up. I copied the code directly from your link.

After looking at your code, your collection is outputting HTML and not XML. (Do a “View Source” on your collection feed url, and you will see a bunch of DIV tags… I don’t see any of the g:tags that should be present). The only things I can think of are one of:

1. You didn’t copy/paste the code correctly into your collection template, or…
2. You didn’t select the correct collection template when creating your collection, or…
3. You are using the incorrect collection url to submit to Facebook…

Second, a little help.
When visiting the collections page I’m gettin Liquid error: Memory limits exceeded.
and then, when uploading the catalog, Facebook says that the file is unsupported. (the template is assigned to the collection).

Memory limits exceeded is likely that you have “too many” products to be included in a single file. One solution is to upgrade to Shopify Plus (which removes most limits). A cheaper solution is one or some of:

– Create multiple collections/feeds for each of your product categories
– Reduce the number in the “paginate collection.products by 1000” line at the top of the template script. Try reducing this to 100 and keep increasing until you get at a number that doesn’t give you the memory error. Then you will need to submit multiple versions of this feed with a &page=2, &page=3, etc… appended to the end of the url to access each page of products. Not ideal, but it’s a workaround.

It seems there’s no products showing up on page=2 — I suspect page 1 is getting all the products, and so page 2 is just blank. (FYI, if you do a “view source” on page 2, you will in fact see the xml code, just with no products listed)

Try reducing the pagination down until page 1 is displayed consistently.

Thanks for putting this together, i have downloaded latest template from the github link you provided in comments but the issue is my feed is not showing up as xml in browser when i view it. Any idea how to resolve it?

The issue is likely that the new template was not selected when the collection was created. If you go back and edit your collection, there should be an option to select a collection template in the bottom right corner. Choose the FB XML feed collection template you created and you should be good to go.

How long does it take for Shopify to accept the invitation?
I’ve been waiting for 7 days Shopify(request pending) 682996421754060
ive talked with Shopify support, they have no idea and they say it is on the FB end not a Shopify related SMH

Sorry for the late reply. See my update/note at the end of the post about the Shopify Facebook Sales Channel. I suspect the approval process is either “manual” or automated but with some very extremely specific scenarios under which a request gets approved. In both cases, if you don’t see an approval within 24 hours, I suspect the approval will *never* happen.

Since shopify stopped the google shopping app, does it still work as expected? I used to have google shopping app but switched over to google shopping channel offered by shopify?
Also my facebook product feed sometimes shows no images for certain products is there a reason why it is doing that?
Thanks!

I think this script will eventually become obsolete as Shopify builds out more robust and proper integrations for Facebook, Shopping, etc… I have it on my Todo list over the coming weeks to revisit this and other scripts and give a more definite answer.

Thanks for the quick reply! I actually did update the feed with the link from your github and the product feed images show now and takes out all duplicate variations, and it works! It was probably because I had an outdated one like you said and didn’t update the script.
In my case, it still works even though I’m using the google shopping channel instead.

Sorry – no good ideas on my end on how to add an extension to the collection url. One option would be to try use a 3rd party to create reverse proxy to map something like feeds.myshopify.com/feed1.xml -> mysite.myshopify.com/collecitons/feed. But I haven’t researched if such services are available, etc…

Although this script (and the Google Merchant Script) will run without the Shopify Google Shopping App, it relies on the app to properly set the Google Shopping Category, as well as Age and Gender properties. So if you don’t want to use the app, you will need to modify the script to assign these values in some other way (either hard-coded, or using an “if” statement)

I’ve had issues with the default Shopify integration as well (I believe the implementation has changed several times over the past year). Currently I see the same behaviour — only the top product id is being passed to Facebook.

The work-around would be to add some custom event code to your product page to trigger an additional “viewcontent” event. I’ll try to implement this and post it as I have time (hopefully in the next couple of months).

HOWEVER, I’m not sure if this is a good idea, as you will now have double the product views, and double the add to cart events, etc… Which may lead to double attribution, and double the conversion value being sent to your Facebook business manager:

But, on the positive side, your dynamic product remarketing should show the correct image / product variant, which should lead to better performance.

It will all come down to if Facebook is smart enough to figure out that the product_group + product are actually the same thing and dedublicate it.

Long term, I think that you either have to wait for Shopify to update their implementation, or to NOT use the default Shopify implementation and make your own custom implementation…

Half a year later.. I’m working with my client again on Facebook related retargeting and they’re now trying to provide offline conversion data to Facebook. I’m now worried that the uploaded data is going to have a high chance of being useless since they have quite a few variations per product so the purchases most likely won’t attribute to the product group advertisement.

Have you heard from the community or Shopify of any changes in the way they submit event tracking to Facebook?

Everything has been working great for me so far, except I seem to be getting two listings for each product (one with an image and one without). I’m guessing, this has something to do with the variants, but I was wondering what might be the best way to fix this?

I’m expriencing the same issue.
From what i see, it looks like products without variant gets duplicated.
1 feed item with an image (without variant # at the end of link)
1 feed item with no image (with a variant # at the end of link)

Hi, your tutorial is great and everything is working smoothly, except the product images. If I look in the feed, the image URLs is correct, and shows the products, but when I import to Business manager, all products successfully gets imported, but all of them has no image. Do you have a solution for this?

Thanks for getting back to me. I really appreciate it. This stuff is definitely testing my technical know how! I had been looking at various product feed management services as a solution the downside being that they are all quite expensive and could possibly be overkill?

Following on from your reply I also had a look and found a variety of apps (both free and paid) in the Shopify app store that seems to offer pretty powerful options when it comes to adding metafields. For instance…

So with the metafields option am I correct in thinking that I could create additional metafields in order to create an alternate title and alternate product description and somehow configure it so that those fields did not display on my actual Shopify store but were used by the product feed instead of the standard title and product feed. I am not sure that the standard Google Shopping Shopify app that most stores use allows for this type of functionality?

By default, MetaFields DO NOT show up on your store unless you explicitly want them to. So you would create 2 new metafields (You need to specify a “namespace” for them — like a top level category — I recommend you use the “google” namespace to keep things consistent with how the Google Shopping app work). Assuming you call the metafields google.title and google.description, you would just update the script code to use product.metafields.google.tilte and product.metafields.google.description (instead of product.title and product.description).

A bigger question for you to ask yourself: Is the extra effort and overhead worth the extra sales you are expecting to generate? Going this route means you will theoretically have to manage 3 sets of Titles and Descriptions (The public description, the SEO description, and then your custom Shopping descriptions). I’m not sure what your assumptions are about increased sales due to these optimizations, but I would crunch some numbers first to see if your sales volume supports the overhead of optimizing the descriptions. (Eg: Assume a 10% increase in sales — what does that come to over the period of a year).

I just realized that we are talking about the Facebook shopping feed and not the Google shopping feed. My previous comment was related to Google Shopping and not facebook (although all the metafields comments are still correct).

RE: Facebook – I assume you want to display the description in the product ads, and so need to make it shorter, etc… That makes sense. But I would again make the calculation of how much conversion lift you are expecting from a slightly better description, and if that’s worth the additional short & long term administrative overhead.

Hi Alex, I am wanting the product descriptions for my products on Google Shopping and my Facebook Feed to be different from those on my Shopify store (basically optimised for these channels). Most of the apps I have come across ( the free Google Shopping Shopify app for instance) just pull the product descriptions directly from your Shopify store and don’t give you the option to edit/change them. Can you recommend a solution that would allow me to edit the product descriptions so they differ from those on my Shopify store?

One option is to use the Shopify SEO Title and SEO Description for your feed’s description. But if you’re already using this for your actual SEO description, then that’s not an option.

The other option would be to use a custom Shopify MetaField to store a third description for each product. There are various metafield editor apps available, as well as a Chrome extension that will allow you to edit them easily. That’s probably your best bet.

Holy ****ing ****!!! You finally got this to work for me! I’ve been trying to get a shopify collection feed to spit out a product feed readable by Facebook for about 3 weeks. Your solution has lead me to believe that we may have stripped essential code from our standard collection template file. The one caveat I’ve found is that you have to make the collection visible on online store in order for it the link to be readable by Facebook’s Product Feed input. This means people could hit that collection page and see a giant block of text. Maybe we can find a work around but again, THANK YOU kind sir. You are a saint.