Course overviewGoogle Search · Build a search performance report
Compare result positions
Measure result CTR using impressions and distinct clicked result keys.
Step 1 of 3 · Learn
Count at result-impression level
Each search_results row is an impression identified by (search_id, position). Result CTR at a position is clicked impressions divided by all impressions at that position. This differs from search CTR: one search can contribute several result impressions.
Collapse repeated clicks on a result
Deduplicate clicks using both search_id and position, then attach a marker to search_results with a one-to-one left merge. Repeated clicks on the same result count once; clicks on different positions within a search remain separate.
index
search
position
event
0
10
1
1
1
10
1
2
2
10
2
3
3
20
1
4
↓
index
search
position
clicked
0
10
1
1
2
10
2
1
3
20
1
1
Four events identify three clicked impressions, not two clicked searches.
Keep positions with no clicks
Fill absent markers with 0 and group the full impression table by position. Count rows for impressions and sum markers for clicked_results. Divide within each position and retain positions with zero clicked results.
index
position
clicked
0
1
1
1
1
0
2
2
0
↓
index
position
impressions
clicked_results
result_ctr
0
1
2
1
0.5
1
2
1
0
0
The unclicked second position stays in the report with a rate of zero.
▷ Your turn
From search_results, return position and impressions, counting every result row once within its position. Sort position ascending and save the DataFrame as result.