{
  "id": 17854129,
  "title": "Pulling Daily Google Ads Cost by Country Into a CSV With Python",
  "url": "https://urgent.news/2026/11/02/pulling-daily-google-ads-cost-by-country-into-a-csv-with-python",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-02T20:59:13.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/pandawm/pulling-daily-google-ads-cost-by-country-into-a-csv-with-python-2pi9"
  },
  "original_language": "en",
  "account": "Advertisers operating in multiple countries often require a daily Google Ads cost report. This file contains essential data such as the date, country, campaign, cost, clicks, and conversions. While manual exporting is impractical, the Google Ads API can provide this information with a single query.\n\nTo access the data, you need a developer token, OAuth credentials, and the customer ID of the account. Install the official client library and store credentials securely in a google-ads.yaml file outside the repository.\n\nThe Google Ads Query Language functions similarly to SQL. The geographic view allows retrieval of cost per country. Using the GoogleAdsClient, load the configuration from the google-ads.yaml file and access the GoogleAdsService. Define the CUSTOMER_ID as 1234567890 and calculate yesterday's date using the datetime module.\n\nConstruct the query to select date, country_criterion_id, campaign name, cost, clicks, and conversions from the geographic_view where the date matches yesterday. Initialize an empty list to store the rows of data. Iterate through the search_stream results, appending each row to the list. Write the data to a CSV file named gads-YYYY-MM-DD.csv using the csv writer.\n\nTo differentiate countries, download the geo targets CSV once and join on it or query geo_target_constant for the IDs encountered. Remember, cost is reported in the account's currency and time zone. If multiple accounts use different currencies, convert to a single currency for consistency. Ensure the file includes a currency column for finance audits.\n\nSchedule the script to run daily using cron or a cloud function, storing the CSV files in shared storage. Implement a simple check to alert if the previous day's cost is zero or exceeds double the seven-day average. This helps detect tracking issues, paused billing, or unexpected campaign performance.\n\nBy consolidating daily cost data by country, you can analyze return on ad spend (ROAS) per market and allocate budget accordingly. The script also provides a foundation for sanity-checking targets before scaling operations. PandaWM, an overseas marketing team based in Hong Kong, utilizes this approach to streamline their advertising analytics.",
  "summary": "Teams advertising in several countries often need one simple daily file: date, country, campaign, cost, clicks and conversions. Finance wants it for reconciliation, growth wants it for ROAS checks. Exporting by hand every morning does not scale. The Google Ads API can produce it with one query. Setup You need a developer token, OAuth credentials and the customer ID of the account (or a manager…",
  "key_points": [
    "Advertisers need daily Google Ads cost report by country",
    "Google Ads API provides data with single query",
    "Python script consolidates cost data by country"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}