Categories
Digital Marketing Google Ads Shopify Shopping

Add Sale Price to Shopify’s Google Shopping feed

This post is deprecated. Shopify now correctly sends Sale Price to Google Merchant Center.

DEPRECATED: As of at least Aug 30, 2022, the defautlt Google sales channel properly sends the product’s sale price to Google. This post and code are no longer being maintained, and are here only for reference.

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.

Create a Price Feed in Shopify

The first step is to create a data feed in Shopify containing your products sale and regular prices. 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

{% layout none %}<?xml version="1.0"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
{% paginate collection.products by 1000 %}
{%- case shop.currency -%}
{%- when 'USD' -%}{%- assign CountryCode = 'US' -%}
{%- when 'CAD' -%}{%- assign CountryCode = 'CA' -%}
{%- when 'GBP' -%}{%- assign CountryCode = 'GB' -%}
{%- when 'AUD' -%}{%- assign CountryCode = 'AU' -%}
{%- else -%}{%- assign CountryCode = 'US' -%}
{%- endcase -%}
<channel>
<title>{{ shop.name }} {{ collection.title | strip_html | strip_newlines | replace: '&', '&amp;' }}</title>
<link>{{ shop.url }}</link>
<description>{{ collection.description | strip_html | strip_newlines | replace: '&', '&amp;' }}</description>
{% for product in collection.products %} 
  {% for variant in product.variants %}
    {%- if variant.compare_at_price > variant.price -%}
      {%- assign OnSale = true -%}
      {%- assign Price = variant.compare_at_price -%}
      {%- assign SalePrice = variant.price -%}
        <item>
            <g:item_group_id>shopify_{{ CountryCode }}_{{ product.id }}</g:item_group_id>
            <g:id>shopify_{{ CountryCode }}_{{ product.id }}_{{ variant.id }}</g:id>
            <g:price>{{ Price | money_without_currency }} {{ shop.currency }}</g:price>
            <g:sale_price>{{ SalePrice | money_without_currency }} {{ shop.currency }}</g:sale_price>
        </item>
    {%- endif -%}
{% endfor %}
{% endfor %}
</channel>
</rss>
{% endpaginate %}

Also available on github

2. Create a new collection called “google-feed-sale-price” based on your Collection Template

  • IMPORTANT Choose xml-pricing-feed as your collection template
  • Add products to the collection (or you can create an automatic collection with Compare At Price is Greater than 1)

3. Preview the collection and copy the url.

  • Your url should look something like this: yourstoredomain.com/collections/google-feed-sale-price
  • When you preview your page, it should look like a bunch of unformatted text on your page. If you see images, then you probably skipped the first bullet point in Step 2.

Add a Supplemental Data Feed in Google Merchant Center

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

  • Name: Sale Pricing Update
  • Feed Type: Scheduled Fetch
  • File Name: google-feed-sale-price
  • File Url: yourstoredomain.com/collections/google-feed-sale-price

Leave everything else as default values and click Continue

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

6. 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 pricing data immediately.

Done

It may take up to 30 minutes for your main feed to be updated. Any new sale pricing will now be uploaded once per day.

Related Reading

37 replies on “Add Sale Price to Shopify’s Google Shopping feed”

This is a very smart solution. I tried and sale price are populating in merchant center. However, ads are still showing only higher prices and not the sales prices. Did you experience such issue?

Like

Two questions:
1) the template creates an error in the title tag in the html code of the page …/collections/google-feed-sale-price
my site Liquid error: wrong number of arguments (given 1, expected 2..3)

2) it is possible to exclude from indexing search through robots.txt or index nofollow the page …/collections/google-feed-sale-price

Thank you!

Like

You may need to fix the code again, not sure, but after 48 hours, on one site, all the Buy on Google Shopping items, ended up showing as

Duplicate Variant – Submit more unique values for this variant – For Buy on Google.
There are no duplicates of these variants. So I think there is an error, and it is causing Google Shopping to think there are duplicate variants.

Like

Hi Tim,
After looking at this, I’ve noticed that Shopify appears to now correctly send the product’s Sale Price to Merchant Center (on the accounts I manage anyway), and so:
1) I am deprecating this script and post, as I believe it is now redundant
2) The error you are getting could be related to this, as if the Sale Price is already in the main feed, then your supplementary feed isn’t adding any new data, and so you appear to be submitting duplicate variants.

I would double check if you are received Sale Price from the main feed.

Like

You are correct after removing the script it fixes itself. Also performance max campaigns let you show a coupon on the ads/products.

Like

Hi, great article and thanks for the help… anyway to show this as .xml in the browser for other affiliates – just now you have to use “view-source:” before the url to see the data ?

Again thanks for the article 🙂

Like

Great Post! Easy to follow. The only issue for me, is that the price in is showing the sale price, but it’s not displayed with the “sales” icon or pop that some of the other listings get. So, the correct price is showing now not the compared at price, it just doesnt say on sale. Any thoughts? Thank you!

Like

Sorry for the late reply.

Your product needs to have been at the “compare at price” for a certain amount of time so that the “SALE” annotation shows up. Also, if the product has been “on sale” for too long, then the SALE annotation might disappear… and then there’s also the case where Google sometimes just decides to do it’s own thing…

Like

Thanks for your response Alex, appreciate it. Do you happen to know the window of time, ie 2 weeks to 6 weeks for the sales pop to appear or is it random? we have approx 100 products on sale, some are rotated every few weeks and others show the compared at price for longer, up to 1 year.

Like

Unfortunately, I’ve never looked into it at this level of detail. All I know for sure is that it’s not consistent. I think you’ll need to do some Google research on this. (But if you do find an answer, please share, as I would love to get the details).

Like

Found the requirement on this page: https://support.google.com/merchants/answer/9017019?hl=en

Requirements
In order for your product to show with sale price annotations, you need to meet certain requirements:

The base price, or the higher price, must have been charged for a period of 30 days (do not need to be consecutive) in the past 200 days.
The base price must be valid.
The sale price must be lower than the base price.
The discount of the sale must be greater than 5% and less than 90%.

Like

If you’d like a content idea for another article. Write about and provide the code to create a local inventory feed.for local ads and local shopping. Myself and others have been searching for a year for a guide on this without having to pay for DataFeedWatch or some third party because we’re too small.

Like

Hi Thank You very much for help with this issue. My google merchant shows that The update could not be matched to an offer. Please make sure to use the identifier of an existing offer and check that the country of sale of the feed is correct. Could You help to solve this error please? Thank You

Like

Hi Joanna — Make sure that the Shopify Google Shopping app/channel is installed and that products are uploaded. Make sure that you only include products in the sale update that are uploaded to the primary google shopping feed.

Like

Is there a lag factor? I just made sure the products uploaded throught he google merchant app that are in google merchant center are in the collection.
For example I have
Items 416 Items matched 416
Offer does not exist 416 Items
I then have a section that says

shopify_US_6179971629215_40694233137311
shopify_US_6179971629215_43077742559479
shopify_US_6179971629215_43077742592247
shopify_US_6179971629215_43118614020343
shopify_US_6179971629215_37868493832351

That is for one store, I have another store with a different them.

Items 290 Items matched 288

Offer does not exist 2 Items
shopify_US_7315903512758_41724944548022
shopify_US_7315903512758_41724944613558

What would you recommend doing? I have gone ahead, and removed any products from the collection that are not syncing with google merchant.

Like

When I click the excel download I see this. This is just a couple of the lines in the excel.
shopify_US_7657708454135_42861382336759 1,689 Offer does not exist Error
shopify_US_7657708454135_42861383188727 2,001 Offer does not exist Error

Like

Hi Alex,

I just set this up and looks like it worked correctly, but will this show a sale tag on the products in google shopping ads? It is only displaying the compare at price, but nothing about a sale.

Like

Hi Marie — Yes, this will cause the SALE price to show up in Google shopping ads. However, the change won’t be instant — it could take a few hours up to a day or so. If by tomorrow the SALE tag is not showing up, then there’s perhaps something wrong with the feed..

Like

Thanks for your tutorial!
But I have a problem, when saving the feed, I get this warning “The file name of the feed is not unique.”
How can I solve? Can I just change the name of the file and the collection?
thank you
Antonio

Like

Hello, great tutorial! Is it normal that the google shopify app directly sends the sale price, which is posted as the actual price, and the full price is not sent to merchant center? Is there a setting to change this?

Like

Currently, yes, this is the normal functionality of the Shopify google shopping app. I assume eventually Shopify will fix this, but the ETA is unknown. There is no setting to change this. The current workaround is to upload a supplemental feed as described in this post.

Like

Hi there thank you very much for this. I have followed all the steps but merchant centre says “Delimiter detection failed” when I try to fetch the feed. Any idea why? Thanks again

Liked by 1 person

Hi Frederics,

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

Hello Alex,

Thank you for getting back to me so quickly, yes you are right I have tried the steps again and discovered when I select to create a new collection template – there is a single line already there when it being setup {% section ‘collection-template’ %} – I didn’t remove this last time, but I did time and everything is fine now. This is guide is a life saver, thank you!

Liked by 1 person

Hi Alex – I take it this is designed for US & CAD only. If for say UK, I need to amend to something like the following:?

{%- assign CountryCode = ‘US’ -%}
{%- if shop.currency == ‘CAD’ -%}{%- assign CountryCode = ‘CA’ -%}
{%- if shop.currency == ‘GBP’ -%}{%- assign CountryCode = ‘UK’ -%}

Like

Thanks Alex. I have this all working now. Just for others, the correct code for UK is actually:

{%- if shop.currency == ‘GBP’ -%}{%- assign CountryCode = ‘GB’ -%}

I had “CountryCode = ‘UK’” before which turns out to be wrong, it needs to be “GB”

Also might be worth tweaking your article a bit Alex to make it a little clearer. When you create the Collection you need to add the products to it e.g. in my case I made it Automatic and set it to Compare At Price is Greater than 1 (so that the collection only outputs items that are on sale)

Like

Leave a comment