# Predict Click Through Rates for Google depending on the Position

I'm given the task to calculate expected click through rates (CTR) for rankings of a given site in Google, using the data Google provides in their Google Search Console. What I get there is basically this:

╔══════════╦════════╦═════════════╦══════════╦═══════╗
║ Queries  ║ Clicks ║ Impressions ║ Position ║  CTR  ║
╠══════════╬════════╬═════════════╬══════════╬═══════╣
║ buffalo  ║      9 ║          20 ║ 1.0      ║ 0.45  ║
║ seattle  ║     20 ║          50 ║ 1.1      ║ 0.4   ║
║ portland ║     10 ║          30 ║ 1.1      ║ 0.333 ║
║ chicago  ║      5 ║         100 ║ 1.1      ║ 0.05  ║
║ new york ║     32 ║         100 ║ 1.2      ║ 0.32  ║
║ houston  ║     10 ║          60 ║ 2.3      ║ 0.16  ║
║ boston   ║      5 ║          40 ║ 2.6      ║ 0.125 ║
╚══════════╩════════╩═════════════╩══════════╩═══════╝


My primary goal is to use this data to predict CTR according to position. Obviously, the higher (lower value) your position in Google is, the higher will be your CTR.

One naive solution would be to calculate the average CTR of a chosen position range and use this as the expected CTR. In the example above for the position ranging from 1.0 to 1.2 we get 76 clicks and 300 impressions resulting in an expected CTR of 0.25. One problem with this kind of calculation are outliers like chicago in our example data. Without it the predicted CTR would be something about 0.35.

Another way is to use a scatter plot and fit a curve e.g. with Excel like in this diagram. The main difference here is that the varying number of impressions is not respected.

I finally learnt that k-nearest-neighbor (kNN) is used for similar kind of predictions. While I'm aware of how kNN works, I wasn't able to adapt it to my task.

So my question is: What's the generic way to deal with such a scenario?

N.B.: I'm fully aware that different queries may have a dramatically different CTR even when being ranked on the same position, depending on factors like type of query (navigational vs. informational for example), the quality of the snippet (title and description) Google is showing or the other sites ranking for that query.

• Is there a long tail of weird queries with very few impressions? Commented Mar 3, 2023 at 6:21

Logistic regression: you model click as function of query and position (ie inputs); in R, you would pass in as targets the counts of clicks and non clicks - eg, use glmnet package in R.