function main() {
  // Configuration
  var NOTIFICATION_EMAIL = ‘your-email@example.com’;
  var problematicCampaigns = [];
  
  // Iterate through active campaigns only
  var campaignIterator = AdsApp.campaigns()
    .withCondition("Status = ENABLED")
    .get();
  
  while (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    
    // Get campaign stats and budget
    var stats = campaign.getStatsFor('LAST_30_DAYS');
    var budget = campaign.getBudget().getAmount();
    
    // Check bidding strategy type
    var biddingStrategy = campaign.bidding();
    
    try {
      // Check if it's a Target CPA strategy
      if (biddingStrategy.getTargetCpa() > 0) {
        var targetCpa = biddingStrategy.getTargetCpa();
        var conversions = stats.getConversions();
        var cost = stats.getCost();
        
        // Calculate actual CPA
        var actualCpa = conversions > 0 ? cost / conversions : 0;
        
        // Compare Target CPA with budget
        if (targetCpa > budget) {
          problematicCampaigns.push({
            name: campaign.getName(),
            targetCpa: targetCpa,
            budget: budget,
            actualCpa: actualCpa,
            conversions: conversions,
            cost: cost
          });
        }
      }
    } catch (e) {
      // Skip campaigns without Target CPA
      continue;
    }
  }
  
  // Send email if problematic campaigns exist
  if (problematicCampaigns.length > 0) {
    var emailBody = 'Campaigns with Target CPA Higher than Budget:\n\n';
    
    problematicCampaigns.forEach(function(campaign) {
      emailBody += 'Campaign: ' + campaign.name + '\n';
      emailBody += 'Target CPA: $' + campaign.targetCpa.toFixed(2) + '\n';
      emailBody += 'Budget: $' + campaign.budget.toFixed(2) + '\n';
      emailBody += 'Actual CPA: $' + campaign.actualCpa.toFixed(2) + '\n';
      emailBody += 'Conversions: ' + campaign.conversions + '\n';
      emailBody += 'Total Cost: $' + campaign.cost.toFixed(2) + '\n\n';
    });
    
    MailApp.sendEmail({
      to: NOTIFICATION_EMAIL,
      subject: 'Google Ads: Campaigns with CPA Exceeding Budget',
      body: emailBody
    });
    
    Logger.log('Email sent with ' + problematicCampaigns.length + ' problematic campaigns.');
  } else {
    Logger.log('No campaigns found with Target CPA higher than Budget.');
  }
}