Google Flights IMPORTXML not working: why, and what works
Your IMPORTXML on a Google Flights link returns an error or nothing. It is not your XPath. Copy this line into a cell instead:
=SONAR_FLIGHT("CDG", "JFK", TODAY()+30)
It returns the lowest Google Flights price for that route and date, as a normal cell value. Add a fourth value for a return date; leave it empty for one-way.
After installing: Extensions › SheetSonar › Get a free key (no sign-up, no card), then paste the formula. A new search can take up to a minute (⏳ in the cell meanwhile).
Why IMPORTXML returns nothing
Google Flights builds its results in the browser with JavaScript. IMPORTXML, IMPORTHTML and IMPORTDATA read the page exactly as the server sends it, and never run that JavaScript, so there is no price in what they receive and no XPath can find one. Rewriting the XPath, or trying another link, will not change that.
What else people try
- Flight APIs: they work, but need a key, a script and usually a paid plan.
- Python scripts: they need a place to run, and break when Google changes its pages.
- A Sheets add-on that does the search for you and returns the price in a cell: that is what SheetSonar does.
Variations
- Several airports:
"PAR"(all Paris airports) or"CDG+ORY". - Another currency:
=SONAR_FLIGHT("JFK", "LHR", C2, , "USD"). Default: the currency of the spreadsheet's country. - More than the price: add
"detail"as the sixth value to get the currency, Google's price level (low, typical, high) and the flight.
For a ready-made sheet with one route per row, see the flight price tracker template. To find the cheapest day to leave, see cheapest day to fly.
What it costs
The free plan gives 20 results a month; a result is one route on one date. A price is kept for 3 hours, so asking again within that time is free, and empty or failed searches are free too. Pro gives 1,000 results a month for €9.90. Plans.
Install SheetSonarFlight price tracker
Prices come from Google Flights' public pages at the time of the search and can change before you book. Always check the final price with the airline or on Google Flights.