Introduction
Despite utilizing the same tbs
parameter as Google Search, News, Images, and Videos, Google Shopping filters are more dynamic, and the values change depending on your search query. In this blog post, we'll go through many possible filters and how to find and use them.
Sorting results to your liking
There are four different ways you can sort your results in Google Shopping. All four of them are constant, and the values are as below:
- Sort results by relevance with the
tbs=p_ord:r
parameter. This is the default sorting with Google Shopping API, so you don't need to provide it. - Sort results by the review score with the
tbs=p_ord:rv
parameter. - Sort results by the price, from lowest to highest, with the
tbs=p_ord:p
parameter. - Sort results by the price, from highest to lowest, with the
tbs=p_ord:pd
parameter.
Dynamic filters in Google Shopping
While sorting filters are the same, no matter the query, the other parameters may vary depending on what you are looking for. We will discuss how to find those filters with Google Shopping API and use them correctly. Please remember that some filters are the same for each search, and only values are dynamic, while others may be totally specific to a given keyword.
Finding available filters for your query
There are two easy ways to find filters available for your search. The first one, recommended, is by running your search query with all parameters and checking the JSON response for the filters
block, like in the example below:
You can then grab the filters you need and use them in the following query to get the results you are looking for.
The second way is to run your query directly through Google Shopping, apply appropriate filters, and check the URL for the tbs
value. An example can be seen below:
While the method is up to you, we strongly recommend the first one, as it's more efficient if you are looking for all the filters for a given query. With the second method, you must perform multiple searches to extract all available filters. With the first method, you only need to make one API call with our Google Shopping API.
The Show only
and Price
filters
Those two filters will likely be available for most of your searches. The values may change, but the filter itself should still be available.
We'll use the default Coffee
keyword to discuss examples, but you can adjust your parameters and check available filters, as explained above.
For the Show only
filter, there are three options available for our query. Below you can find examples with the proper tbs
values for each:
- Buy on Google with the
tbs=mr:1,buy:g
parameter - On sale with the
tbs=mr:1,sales:1
parameter - Available nearby with the
tbs=mr:1,local_avail:1
parameter - You can even use all of those filters at once with the
tbs=mr:1,local_avail:1,ss:55,sales:1,buy:g
parameter
The Price
filter can be used to specify the price ranges for your search or to set the minimum or maximum price. The price ranges are always constructed with the tbs=mr:1,price:1,ppr_min:X,ppr_max:Y
parameter, where the X value is the minimum price, and the Y value is the maximum price. If you want to set only minimum or maximum value, you can just drop the ppr_max:Y
or ppr_min:X
parts from the tbs parameter.
- Up to $10 with the
tbs=mr:1,price:1,ppr_max:10
parameter - $10 - $100 with the
tbs=mr:1,price:1,ppr_min:10,ppr_max:100
parameter - Over $100 with the
tbs=mr:1,price:1,ppr_min:100
parameter
Using query-dependent dynamic filters
As mentioned above, some filters are only available for specific keywords. For example, for the q=Coffee
, you can find Flavor
, Container Type
or Roast
among filters. While those are available for the Coffee
search, they will be different for queries like Playstation
or Football
.
These filters, even though they change from query to query, are used the same way as the ones mentioned above. Below you can find a couple of examples:
- Medium roast with the
tbs=mr:1,pdtr0:973849|973851
parameter - Chocolate flavor with the
tbs=mr:1,pdtr0:1658504|1658508
parameter - Coffee contained in a jar with the
tbs=mr:1,pdtr0:1658497|1658499
parameter
Combining different types of filters
Combining filters is not as straightforward as you might think. Your tbs
value always needs to start with mr:1
no matter how many filters you'd like to apply. The 2nd part of the tbs
value depends on the filter you choose. For example, the tbs
value for the Brand=Jacobs
is mr:1,pdtr0:906016|3136105
, and for the Flavor=Chocolate
is mr:1,pdtr0:1658504|1658508
. They need to be combined in the following way:
As you can see, both of the filters contain the pdtr0
part. However, since those are different types of filters, they need to be separated by a comma, and the 2nd filter used needs to have pdtr1
instead of pdtr0
. This is the same if you'd like to use three or more filters of different types. The pdtr0
changes to pdtr2
, pdtr3
, and so on. Example below:
Some filters do not contain the pdtr0
part. In that case, simply combine the parts after mr1
of different filters:
Combining filters from the same type
For filters of the same type, you need first to find the common part of the filter and combine it with the unique part of each filter you want to use, separated with the correct separator . For example, Brand
filters are as below:
You can see that the common part for each of them is mr:1,pdtr0:906016|
, and the unique parts are 1083000
for NESCAFÉ
, 3136105
for Jacobs
, and so on. Simply combine the common part with the unique part of each Brand
separated by !
:
For the Sellers
filter, the applicable separator is |
. Once again, you need to find the common part for each filter of that type and combine it with the unique parts of each filter:
There could be other separators like ,
or ;
. The easiest way to find the separator for your filter is to perform an API call with one of the filters and check what values are provided for the 2nd filter of the same type:
Conclusion
As you can see, the Google Shopping filters are more dynamic than Google Search, News, Images, and Videos filters. If you want to test your implementation, I recommend checking the Playground first. If you are interested in filtering results for different Google engines, check the blog posts below:
Filtering Google Search and Google News results
Filtering Google Images and Google Videos results
You can also contact us directly with any questions or concerns at contact@serpapi.com. We will be more than happy to help!
Check our Tips and Tricks blog post
Use the Playground to test our APIs
Join us on Twitter | YouTube