Cost of Goods Sold (COGS) is the direct cost of producing whatever a business sells — raw materials, direct labor, and manufacturing or production overhead. It does not include indirect costs like marketing, sales salaries, rent, or general administration — those are operating expenses (OpEx), tracked separately.
The formula
For a service or software business without physical inventory, COGS is usually approximated as the direct cost of delivering the service — e.g. hosting costs and support staff for a SaaS product, or materials and direct labor for a freelancer's project.
Why COGS matters
COGS is the input to gross margin — revenue minus COGS, divided by revenue — which is the single most-watched profitability metric for any product or service business. A software company with 80%+ gross margin (low COGS relative to revenue) can reinvest heavily in growth; a business with 20% gross margin has much less room to spend on anything beyond production.