Digital Marketing Google Ads Shopify Shopping

Enhance Shopify’s Google Shopping feed

Augment your Google Shopping Feed with Sale Price, Additional Variant Images by color, Automatic Exclusion of Out of Stock varaints, and Intelligent Exclusion of Low Stock color variants.

The following script will allow you to enhance Shopify’s Google Shopping app feed to include:

  • Sale Price annotations
  • Additional Images by Variant: More control over which product images get associated with which variant.
  • Exclude Out of Stock items from Google Programs. If you are paying to advertise, make sure you are only paying to display products you can sell.
  • Exclude Low Stock variants from Google Programs. Exclude color ways that have low size options. Show other color options or products instead.
Sale annotation in Google Shopping
SALE labels and price markdown annotations usually only appear if you provide Google Shopping with both your regular price (compare_at_price) and your sale price.

To add the above functionality, you must create and upload a supplemental data feed to Google Merchant Center.

Step 1
Create a Supplemental Data Feed in Shopify

The first step is to create a data feed in Shopify. We can accomplish this by creating a custom Shopify Collection Template that will output XML data instead of HTML:

1. Create a new Collection Template called with the following code:

{% layout none %}<?xml version="1.0"?>
<rss xmlns:g="" version="2.0">

{% comment %}
Google Shopping / Merchant Center + Shopify Product Update Feed by Alex Czartoryski

This version: Oct 14, 2020
The latest version of this script available here:
{% endcomment %}

{% comment %} Settings {% endcomment %}
{%- assign exclude_unavailable_variants = true -%}
{%- assign exclude_variant_colors_with_limited_availability = true -%}
{%- assign ignore_x_smallest_sizes = 1 -%}
{%- assign ignore_x_largest_sizes = 1 -%}
{%- assign minimum_percentage_availability = 50 -%}
{%- assign filter_variantImages_byColor = true -%}

{%- assign CountryCode = 'US' -%}
{%- if shop.currency == 'CAD' -%}{%- assign CountryCode = 'CA' -%}{%- endif -%}

<title>{{ }} {{ collection.title | strip_html | strip_newlines | replace: '&', '&amp;' }}</title>
<link>{{ shop.url }}</link>
<description>{{ collection.description | strip_html | strip_newlines | replace: '&', '&amp;' }}</description>

{%- paginate collection.products by 1000 -%}
{%- for product in collection.products -%}

{%- comment -%} Get color option {%- endcomment -%}
{%- for option in product.options -%}
{%- if option == 'Color' -%}{% capture option_color %}option{{ forloop.index }}{% endcapture %}{%- endif -%}
{%- endfor -%}

{%- comment -%} Make a list of Colors to exclude {%- endcomment -%}
{%- assign colors_to_exclude = "" -%}
{%- if exclude_variant_colors_with_limited_availability -%}
{%- for color in product.options_by_name['Color'].values -%}
{%- assign variants = product.variants | where: option_color, color -%}
{%- assign variants_to_process_count = variants.size | minus:ignore_x_smallest_sizes | minus:ignore_x_largest_sizes -%}
{%- assign available_count = 0 -%}
{%- assign total_processed_count = 0 -%}
{%- for variant in variants offset:ignore_x_smallest_sizes limit:variants_to_process_count -%}
{%- assign total_processed_count = total_processed_count | plus:1 -%}
{%- if variant.available -%}{%- assign available_count = available_count | plus:1 -%}{%- endif -%}
{%- endfor -%}
{%- if total_processed_count == 0 -%}
{%- continue -%}
{%- endif -%}
{%- assign percentage_availability = available_count | times: 100.0 | divided_by: total_processed_count | round -%}
{%- if percentage_availability < minimum_percentage_availability -%}
{% capture colors_to_exclude %}{{colors_to_exclude}}#{{ color }}{%endcapture%}
{%- endif -%}
{%- endfor -%}
{%- assign colors_to_exclude = colors_to_exclude | split: "#" -%}
{%- endif -%}

{%- for variant in product.variants -%}
<g:item_group_id>shopify_{{ CountryCode }}_{{ }}</g:item_group_id>
<g:id>shopify_{{ CountryCode }}_{{ }}_{{ }}</g:id>
<g:mpn>{{ variant.sku }}</g:mpn>

{%- comment -%} Sale Price {%- endcomment -%}
{%- if variant.compare_at_price > variant.price -%}
{%- assign variant_onSale = true -%}
{%- assign variant_price = variant.compare_at_price -%}
{%- assign variant_salePrice = variant.price -%}
<g:price>{{ variant_price | money_without_currency }} {{ shop.currency }}</g:price>
<g:sale_price>{{ variant_salePrice | money_without_currency }} {{ shop.currency }}</g:sale_price>
{% endif %}

{%- comment -%} Additional Images by Color {%- endcomment -%}
{%- assign additional_images = product.images -%}
{%- for option in product.options -%}
{%- if option == 'Color' -%}{% capture variant_color %}{{ variant.options[forloop.index0] }}{% endcapture %}{%- endif -%}
{%- endfor -%}
{% if filter_variantImages_byColor %}{% assign additional_images = product.images | where: "alt", variant_color | sort: 'attached_to_variant' | reverse%}{% endif %}
{% 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 %}

{%- comment -%} Exclude Out of Stock Variants {%- endcomment -%}
{% if exclude_unavailable_variants and variant.available == false %}
<g:excluded_destination>Display ads</g:excluded_destination>
<g:excluded_destination>Shopping ads</g:excluded_destination>
<g:excluded_destination>Shopping Actions</g:excluded_destination>
{% elsif exclude_variant_colors_with_limited_availability and colors_to_exclude contains variant_color %}
<g:excluded_destination>Display ads</g:excluded_destination>
<g:excluded_destination>Shopping ads</g:excluded_destination>
<g:excluded_destination>Shopping Actions</g:excluded_destination>
{% endif %}

{% endfor %}
{% endfor %}
{% endpaginate %}

Available on github here

2. Create a new collection called “google-update” and choose google-update as your collection template.

3. Preview the collection and copy the url. Your url should look something like this:

Step 2
Configure your Feed

There are a few options you can configure in your feed, all located towards the top of your template file in the “configuration” section.

Sale Priceautomatic
Exclude Out of Stock Variants

Exclude Limited Stock Color Variants

Filter Variant Images by Color + Alt Text Matching


Sale Price

This is automatically included. If your products have a current price that is less than the compare_at_price then the appropriate sale price data will be automatically updated in the feed.

Exclude Out of Stock Variants

exclude_unavailable_variants = true

By default, any variants that are out of stock will be excluded from Google Shopping, Google Shopping Actions, and Dynamic Remarketing. Change the value of exclude_unavailable_variants = false if you want to disable this behaviour.

Exclude Limited Stock Color Variants

exclude_variant_colors_with_limited_availability = true

This setting is intended for apparel products, where you may have many colors of a product, but limited sizes available in a specific product. Setting this value to true will cause the script to attempt to exclude the colors with low availability (so that alternative colors or products can show instead).

There are a few additional configuration items for this setting that you can change:

default = 50
Minimum % of sizes available before all variants of this color are excluded.
default = 1
Ignore the x smallest sizes in the % available calculation
default = 1
Ignore the x largest sizes in the % available calculation

Filter Variant Images by Color
and Alt Text Matching

filter_variantImages_byColor = true

Setting this value to true will assign additional images to the current variant where the image’s Alt Text matches the variant’s color. Note that the primary variant’s image will always be included in the feed regardless of Alt text.

Step 3
Add a Supplemental Data Feed in Google Merchant Center

1. Open Merchant Center and go to
Products > Feeds > Supplemental Feeds > Add Supplemental Feed

NameFeed Update Script
Feed TypeScheduled Fetch
File Namegoogle-update

Leave everything else as default values and click Continue

2. Make sure there’s a checkmark beside Content API and click Create Feed

3. You should now see your newly created feed in the Supplemental Feeds section. Click on your feed’s name and then click on Fetch Now to update your product data now.


It may take up to 30 minutes for your main feed to be updated. It is a good idea to review your products and feed to ensure that everything is coming through as expected, and tweak as required.

If everything looks good, your new sale pricing, variant images, and program availability should now be updated once per day.

Related Reading

14 replies on “Enhance Shopify’s Google Shopping feed”

Alex, thanks for the write up!

I really like the concept behind this approach as it gives me full control.

One flaw I believe, is that we can’t paginate by more than 50 items, while your code lists 1000. (

Unfortunately I believe this technique will only works for stores with less than 50 products, as I can’t think of a way to get the feed consumer to paginate.

Thank you for posting this, great stuff!


Hi Max,

Thanks for pointing this out. I mostly work with Shopify Plus stores, and I’ve never hit a pagination limit that I am aware of, so I assume Shopify Plus removes the pagination limit.

A possible workaround would be to create multiple feeds in Google Merchant centre, with ?page=2, ?page=3, etc… appended to each url. This becomes less and less of a viable workaround as the quantity of products increases.

Another workaround would be to create a separate feed for each of your product types / collections (keeping # of products below 50).



I’m getting an error on the merchant centre feed when its loading it in. Its says “delimiter detection failed”
“The column delimiter could not be automatically detected from your feed. To select a column delimiter, click edit next to your feed name in your account and select the correct option.”
What delimiters are used (tabs, space or pipe or something else)? These are the options you can set. I currently have autodetect which is failing.


Hi Mike,

The file is XML and doesn’t use delimiters. Check to make sure that there are no extra spaces or lines at the very beginning of the file, and that you have set the collection template properly for your collection (double check this by loading the url — there shouldn’t be any images showing up).



Hi Alex, I’m still having trouble getting the supplementary feed to work. I’m getting the following error:
Invalid attribute name:
“This attribute name is not allowed. It may contain punctuation or conflict with an official attribute.”
I’d give you a screenshot but I’m not sure this format allows that.
Input method:
Internal Upload
Total file size:
258.50 KB
Detected encoding:
Detected delimiter:
Tab (\t)

I have 4,744 items but zero matching.
Here’s my feed:
Please let me know if you have a solution to this.


Hi Mike,

Sorry for the late reply.

On line 8 of your feed (when viewing source) I see a “}” character.
You probably have a mis-closed variable somewhere in your liquid, towards the start of the file (somewhere before the tag).

If you delete the extra character, I think you’ll be ok.

Liked by 1 person

forget that…i see its a supplemental feed.

I am having difficulty locating the configuration section in Step 2. Are you able to help with that please?

(“located towards the top of your template file in the “configuration” section.)” – not sure where you are referring to.


This is really cool, 1 question. Would something like this app Im using be possible? Im interested at the Google product category feed-gpc-XXX setting my Google Product Category. What about settings all products to custom
clearing g:gtin-field + g:mpn-field and set g:identifier_exists-field to false?
Set g:id-field to variant sku ?


Hi Γιάννης Αθανασίου,
This post is specifically about using Shopify’s Shopping. Although similar techniques should in theory work to augment the feeds generated by other tools.
You can set all your products to custom, but then you’re not giving Google all the information it needs to properly serve your products. But it’s a solution if it’s your only option.



can’t your feed pull and include those options? google product category and all (clearing g:gtin-field + g:mpn-field and set g:identifier_exists-field to false Set g:id-field to variant sku)


Could you please do it? I could pay you if needed. I have no idea about code. Thanks


Leave a Reply

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

You are commenting using your 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