Carbon Intelligence™
The Trade Desk Export Guide — Python Script
GMSF v1.2
The Trade Desk
10 min install
Objective
This Python script automatically exports your The Trade Desk campaign data with the granularity needed for GMSF v1.2 carbon analysis in Carbon Intelligence™. The Trade Desk offers very fine granularity on exchanges, connections, and buy types.
Installation
3 steps · 10 minutes
Prerequisites
- Python 3.8+ installed on your server or local machine
- Install dependencies:
pip install requests pandas - Obtain an API Token and Partner ID from The Trade Desk
- Note the target Advertiser ID for export
Configure the script
- Open the file
carbon-intelligence-thetradedesk-export.py - Fill in the authentication parameters:
API_TOKEN,PARTNER_ID,ADVERTISER_ID - Configure
OUTPUT_DIRfor the CSV destination folder
Run
- Run the script:
python carbon-intelligence-thetradedesk-export.py - Schedule recurring execution via
cron(Linux/macOS) or Task Scheduler (Windows) - Recommendation: weekly (every Monday morning)
What is exported
13 tabs created automatically
| Tab | Content | Usage Carbon Intelligence |
|---|---|---|
| CI_Campaigns | Summary by campaign and day | Emissions overview |
| CI_Device | By device (mobile, desktop, CTV) | Energy factor per device |
| CI_Geo | By country and region | GMSF v1.2 country energy mix |
| CI_Placements | By site and application | Energy-intensive placements |
| CI_CreativeSize | By creative size (300x250, 728x90, etc.) | Data transfer weight |
| CI_AdFormat | By format (Display, Video, Native) | Ad format factor |
| CI_Video | Detailed video data (duration, type) | Video carbon calculation |
| CI_Exchange | By exchange (Rubicon, OpenX, AppNexus, etc.) | 🎯 TTD Specific — Inventory source |
| CI_Connection | By connection type (WiFi, mobile, wired) | 🎯 TTD Specific — Network energy efficiency |
| CI_Environment | By context (app, web, OTT) | 🎯 TTD Specific — Media environment type |
| CI_BuyType | By buy mode (open auction, PMP, PG) | 🎯 TTD Specific — Buy strategy transparency |
| CI_Metadata | Account info, script version, dates | Traceability and audit |
| CI_Export_CSV | All dimensions consolidated | Direct CI platform import |
Export CSV
Two options available
After each script execution, you will find in the
OUTPUT_DIR folder the following CSV files:- •
CI_Export_[DATE].csv— Consolidated file for direct import - •
CI_Campaigns_[DATE].csv— Campaign details - •
CI_Device_[DATE].csv— By device - •
CI_Exchange_[DATE].csv— By exchange (TTD specific) - • ...and other dimensions
Sharing with Carbon Intelligence™
Advanced Configuration
Script CONFIG section
# In the script, CONFIG section:
LOOKBACK_DAYS: 90, # Days of history (default: 90)
MIN_IMPRESSIONS: 1, # Minimum impression threshold per row
REPORT_TIMEZONE: 'UTC', # Report timezone
MAX_RETRIES: 3 # API retry attempts on error
LOOKBACK_DAYS: 90, # Days of history (default: 90)
MIN_IMPRESSIONS: 1, # Minimum impression threshold per row
REPORT_TIMEZONE: 'UTC', # Report timezone
MAX_RETRIES: 3 # API retry attempts on error
Troubleshooting
"401 Unauthorized"
Check that your
API_TOKEN is valid and not expired. Regenerate it if necessary in The Trade Desk console."Advertiser not found"
Check that the
ADVERTISER_ID exists and that your token has access to this account."Report timeout"
The report is taking too long. Reduce
LOOKBACK_DAYS from 90 to 30 days."Empty report"
Check that you have active campaigns with impressions for the period defined by
LOOKBACK_DAYS."Rate limit exceeded"
The Trade Desk API has a quota. Wait a few minutes and try again. Increase
MAX_RETRIES for better resilience.Support
Email
support@carbonintelligence.green
Website
carbonintelligence.green
Script version
1.0.0
Methodology
GMSF v1.2 (Ad Net Zero)