We all know how important it is to have a healthy feed full of attributes that allows Google to perform better by improving matching relevancy. However, sometimes, information is missing in the feed for many different reasons; the backend is not ready to pull some attributes, the information is not available, etc.
This is what happens sometimes with the “color” attribute on Merchant Centre. If you run an e-commerce, Clothing & Apparel business for example, and have lots of product variants/colours, the “color” attribute becomes vitally important. If the product feed does not have this information readily available, and we are unable to get it from the platform (which would be the ideal scenario here!) we’ve outlined a way to automate the process and have the attributes ready in a matter of seconds.
Export from BigQuery
Using BigQuery data transfer service, we can pull a merchant centre export which enables us to see the number of disapproved products as well as all of the feed attributes. This comes handy to create dashboards monitoring the feeds’ health but also to create supplemental feeds to create custom labels, and in this case, add new product attributes.
Download Images
Now we have all the feed attributes ready in BigQuery, we can pull out the “image_link” attribute. We need the image URLs to download the product images and process them later.
The easiest way to download all the image URLs is through the google-cloud-bigquery or pandas-gbq library.
After we get the list of URLs with a simple “Select” SQL statement, we can download the images using the requests library.
Check the Colours
Once we have our images ready, we need to use another two libraries to check the predominant colours in the image: colorthief and webcolors.
For instance, if we have this image:
The script is going to determine that the predominant colour in the picture is: darkslategrey. We can use that colour as an attribute or we can do further maths to extract the predominant color on the “dark slate grey” which in this case can be either green or blue (both have, surprisingly, the same colour % mix).
Send this info to Google Sheets
After you choose whether you want to push a basic colour or the darkslategrey, we can easily send the information to a google sheets spreadsheet by using a library like gspread and have a supplemental feed mapping the ID to the newly extracted “color” attribute.
I hope you can get an idea on how powerful data enrichment can be using the Merchants Data Transfer Service for BigQuery along with scripts like the one described throughout the article.
To learn more about how to optimise your data feed and make the most of all the attributes available, sign up to our Webinar next Thursday 18th of May at 10am (BST).