Google Ads JavaScript Generator
The Google Ads scripting community (practitioners following Nils Rooijmans, Mike Rhodes, Smarter Ecommerce, and the r/PPC community) relies on copy-paste JavaScript snippets that run directly within the Google Ads interface.
Rather than requiring manual CSV uploads into Google Ads Editor, TubeSentry can generate a self-contained, copy-paste JavaScript file that automates placement exclusions directly inside your Google Ads account.
1. Generating the Script via CLI
During an audit, pass --export-script:
tubesentry audit where_ads_showed.csv --export-script cleanup_placements.jsOr export from a report with custom settings:
tubesentry export script \
--report where_ads_showed.csv \
--out cleanup_placements.js \
--list-name "TubeSentry Waste Shield" \
--dry-run2. Generated JavaScript Structure
The generated script is self-contained and formatted for modern Google Ads Scripts (V8 runtime):
var CONFIG = {
// Test mode: true = preview in logs without making actual exclusions; false = apply changes
DRY_RUN: true,
// Exclusion mode: 'SHARED_LIST' (recommended account-wide) or 'CAMPAIGNS'
EXCLUSION_MODE: 'SHARED_LIST',
// Name of the account-level Shared Placement Exclusion List
SHARED_LIST_NAME: 'TubeSentry Waste Shield',
// Filter campaigns by name when using 'CAMPAIGNS' mode
CAMPAIGN_NAME_CONTAINS: '',
// Max exclusions to process per run (Google Ads script limit is 30 minutes)
BATCH_SIZE: 1000
};
var CHANNELS_TO_EXCLUDE = [
"UCbCmjCuTUZos6Inko4u57UQ",
"UCSJ4gkVC6NrvII8umztf0Ow"
// ... all flagged channel IDs
];
function main() {
// Automatically creates or populates the Shared Placement Exclusion List
}3. How to Deploy in Google Ads
- In your Google Ads dashboard, navigate to Tools and Settings > Bulk Actions > Scripts.
- Click the blue + button to create a new script.
- Paste the contents of
cleanup_placements.js. - Click Preview to verify the execution logs in safe dry-run mode.
- In
CONFIG, setDRY_RUN: false, authorize the script, and click Run. - (Optional) Set a daily or weekly schedule to keep your account shielded automatically.
4. Shared List vs. Campaign Mode
SHARED_LISTMode (Recommended): Creates or appends to an account-level Excluded Placement List in the Shared Library. Applying this list to all campaigns blocks flagged channels across Video, Performance Max, and Demand Gen without hitting individual campaign limits.CAMPAIGNSMode: Targets specific campaigns matching--campaign-name-contains.
5. Demand Gen (Dec 1, 2026) & Creative Governance Audit Script
Starting the week of December 1, 2026, Google removes campaign-level Display opt-outs (target_content_network = false) in Demand Gen — causing legacy scripts and bulk uploads to fail with OPERATION_NOT_PERMITTED_FOR_CONTEXT unless Display opt-outs are enforced at the ad-group level (ALL_OWNED_AND_OPERATED_CHANNELS).
Generate a ready-to-paste audit script to inspect your account for breaking Demand Gen configs, default-on auto-generated/enhanced PMax videos (GENERATE_ENHANCED_YOUTUBE_VIDEOS), and Mobile App / GVP spend leakage:
tubesentry export demand-gen-audit --out demand_gen_dec2026_audit.js6. Enterprise Ads Data Hub (ADH) 3-Table SQL
For enterprise teams auditing delivery inside Google's Ads Data Hub clean room, TubeSentry generates the exact 3-table UNION ALL query (adh.google_ads_impressions, adh.google_ads_active_views, and adh.google_ads_creative_conversions joined on impression_id) to measure GroupM Viewability, Audible & Fully Visible Watchtime, and custom AVOC from Q4 quartile telemetry:
tubesentry export adh --out tubesentry_adh_quality.sql --days 30