The Secret Math Behind Google Shopping


You are probably keenly aware (and just as keenly lament) that Google Shopping does not allow you to bid at the keyword level for your products. The burning question, then, is how does Google decide which product to show for a user search query, and perhaps more importantly, how can you utilize this information to chea.. err be more efficient.

Google has a goal function that they’re trying to maximize. To understand why Google shows who it does, we’ll have to put ourselves in their shoes. So pretend you’re Google – what do you care about? Peace on earth, world hunger, and most importantly, Profit.

The Profit Equation

Google makes money when someone clicks on one of the shopping ads below:


google shopping example


But not everyone clicks on an ad, so the question is: On average, how much money will Google make if it shows your ad for this query?

Google’s Profit for showing your ad for this particular search query is roughly the multiplication of the following terms:

  • The number of times someone clicked on your ad divided by the number of times your ad was shown for this particular search query. This is also known as Click Through Rate (CTR conditioned on search query)
  • How much you tell Google you’re willing to pay per click (Max CPC)
  • Total Search Volume


In comparing the expected profit from two competing Ads, Google doesn’t have to take into account Total Search Volume, because it’s a multiplicative term on both competitors.

For example:

c1_profit = (CTR|Query of C1) * (Max CPC of C1) * (Total Search Volume)
c2_profit = (CTR|Query of C2) * (Max CPC of C2) * (Total Search Volume)

If all we’re trying to do is determine which one is higher, we can divide both by Total Search Volume

Great, so we know what the factors at play are, CTR|Query and Max CPC. Your control over both of these factors is HIGHLY dependent on your ability to manipulate your data feed.

CTR | Query

Remember that this is computed as the total number of clicks over the total number of impressions for this particular query.

There are a lot of factors that can affect the propensity of someone to click on your ad:

  • Price Point – How compelling is your price point, especially relative to the other ads showing. If someone else is selling the exact same thing for less, you’re going to have a hard time, both from a click through rate perspective and a conversion rate perspective (they just saw someone else willing to sell it to them for 20% less!)
  • Image – How appealing is your image?
  • Title – Is your product actually what they’re looking for?


However, there’s an additional complexity that we’ve left out of the CTR equation. Confidence and Sample Size!

  • Say Product A has 1 click out of 10 impressions, that gives a click through rate of 10%.
  • Say Product B has 1000 clicks out of 100,000 impressions, that gives a click through rate of 10%.

Google’s going to be a lot more confident in B’s CTR than A’s CTR, even though the sample mean is the same!

How much more confident you ask?

Assume each impression/click opportunity is a random variable with binomial distribution. Each such impression/click opportunity in a collection of such events is independent of one another… I’ll frustratingly leave the rest of the solution as an exercise for the reader ;). In actuality, the problem is found in all facets of life, from Quantum Physics, the basis of String Theory, to the Strong Force in Nuclear Physics. Don’t you wish you paid attention in your probability course now!

Small Sample Sizes, User Happiness, and Textual Similarity

Because the sample size is small (and maybe because Google cares just a little about the satisfaction of its users), Google will use another factor to modulate its understanding of CTR|Query – textual similarity. Take two products:

Product A – Cinnamon Scented Candle
Product B – Cinnamon Scented Candle – Long Lasting

Doesn’t it make sense that if someone searched for: ‘Long lasting cinnamon scented candle’, Product B is better than Product A? Definitely! And you may argue that the CTR|Query already takes this into account, that a user will more likely click on Product B if his search contains long lasting.

There are two main counter-points to this argument.

  1. The ‘visible’ portion of the title will likely cut off before Long Lasting. The user won’t see it, and it thus won’t affect his propensity to click.
  2. It turns out that calculating exact query dependent CTR is computationally expensive, but more importantly, it requires a very very very very very large data set. What do you do with low volume queries or new queries?

And that’s where Textual Similarity comes into play. It’s kind of like Landing Page Quality Score for Text Ads. At a high level, Google is making the assumption that users are more likely to be satisfied with Ads that are similar to their query.

Cosine Similarity – How similar is a query to a product

We’ve already begun the thought process needed to answer this question. Above, we noted that Product B was more similar to “Long Lasting Cinnamon Scented Candle” than Product A was.

Why? Well because Product B had more words in common with the query than Product A.

Take another example:
A – Sony DSLR Camera Lens – 32x Optical Zoom
B – Sony DSLR Camera
Query – Sony DSLR Camera Lens

Again Product B is more similar to the Query. Why? This time the answer lies more in the semantic meaning behind the words (specifically Lens).

Here’s a summary of the stats:

Product A has 4 word matches but 3 extra words (32x optical zoom).
Product B has 3 word matches and 0 extra words.

First, I have to qualify that all of this will be a bit of an approximation. It’s very likely that at least some of the following are true:

  • Google uses alias lists (i.e. tshirt will be treated the same as tee)
  • Google uses positional weighting, words towards the end might be more important
  • Google uses semantic weighting (i.e. nouns are more important)
  • Google may weight consecutive word matches differently
  • Google may use a bayesian classifier to first classify a product into a product_type. It will then restrict results to products that classify as that product_type, at which point it will not incorporate a textual similarity score into the decision to show one product over another.
  • etc.

Cosine Similarity – How good are matches? How bad are extra words?

Let’s get formal about it. There’s a notion in Linear Algebra called the Angle between two vectors.

If we convert our product titles and queries to word count vectors, we can find the ‘angle’ between them. A large angle would indicate a mismatch whereas an angle of 0 would indicate that the vectors are the same.

One Missed Word

Let Q have 4 unique words
Let A and B have 7 unique words
Let A match Q on 4 unique words
Let B match Q on 3 unique words


google merchant secrets


A difference of around 25%

One Extra Word

Let Q have 4 unique words
Let A have 7 unique words
Let B have 8 unique words
Let A match Q on 4 unique words
Let B match Q on 4 unique words


google merchant feeds


A difference of around 7%

In conclusion, an extra word is a much smaller penalty than the penalty of missing a word!!!

Phew, we’ve gone through a lot of math, and maybe it’s not immediately apparent what we should do with our products to make more money. We’ve said quite a bit when all we were really trying to say was stuff your titles and product_types with the keywords you want to show up for.

You might be wondering if the same math works for channels like Amazon, Walmart, or eBay? The answer is yes, it works for any relevancy based search channel or marketplace!