How to calculate Cost per Click (CPC)
Cost per click is the average amount you pay each time someone clicks your ad.
Formula
CPC = total ad cost ÷ total clicksSQL query
This example assumes: ad_stats(campaign, day, cost, clicks). It is written in PostgreSQL syntax; date functions differ slightly in MySQL, BigQuery and SQLite, and your column names will differ from these.
SELECT campaign,
SUM(cost) AS cost,
SUM(clicks) AS clicks,
SUM(cost) / NULLIF(SUM(clicks), 0) AS cpc
FROM ad_stats
WHERE day >= CURRENT_DATE - 30
GROUP BY campaign
ORDER BY cpc;Common mistakes that make Cost per Click (CPC) wrong
- Average of daily CPCs is not the true CPC; divide total cost by total clicks.
- A low CPC is only good if those clicks convert.
- Currency differences across accounts must be normalised before summing.
Ask for Cost per Click (CPC) in plain English
Instead of writing the query yourself, you can type the question. SchemaChat turns it into SQL against your connected database or uploaded file, runs it, and shows the SQL and the figures it used so you can check the answer before you share it. It does not replace your judgement about the definition: check that the query matches the formula your business uses.
- What is our average cost per click by campaign?
- Which campaigns got more expensive per click this month?