google-ads-samples
Skill72 starsChanged 4 months agoMITView on GitHub
Reference library of official Google Ads API code samples. Auto-invoke when building NEW Google Ads scripts, agents, or functionality (campaigns, mutations, reporting, account management). Helps find relevant examples in /examples/ folder before writing custom code. Improves efficiency by starting from proven patterns rather than guessing API implementation.
In this repository41 other files it gives its agents.
- account-diagnosticSkill
- ad-copy-generation-frameworkSkill
- ad-copy-verification-standardSkill
- add-account-negative-keywordsSkill
- ads-checkerSkill
- budget-guardianSkill
- budget-recommendation-calculatorSkill
- change-history-checkerSkill
- client-communication-standardsSkill
- competitor-analysis-v2Skill
- conversion-tracking-healthSkill
- dgen-automation-disableSkill
- fair-housing-complianceSkill
- ga4-campaign-cross-referenceSkill
- ga4-cross-analysisSkill
- ga4-lead-quality-investigationSkill
- gaql-query-patternsSkill
- geo-conflict-analyzerSkill
- google-ads-api-setupSkill
- google-ads-querySkill
- impression-share-diagnosticsSkill
- investigation-methodologySkill
- lead-quality-pattern-analysisSkill
- lead-quality-recommendation-prioritizationSkill
- markdown-to-sheets-presenterSkill
- mcc-hack-auditSkill
- mutation-safetySkill
- neg-conflict-finderSkill
- non-serving-keyword-scannerSkill
- pmax-asset-automationSkill
- pmax-builderSkill
- portfolio-health-prioritizationSkill
- portfolio-pacing-rulesSkill
- rsa-bulk-editSkill
- rsa-refreshSkill
- rsa-single-accountSkill
- shared-budget-updaterSkill
- sqr-classifierSkill
- sqr-pipelineSkill
- underspending-investigationSkill
- youtube-placement-auditSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 34
All paths below reference google-ads-python/examples/ relative to the project root.
- Distinctive: line 118
When invoked, follow this protocol:
- Distinctive: line 123
Operation type: Create, read, update, delete?
- Distinctive: line 168
Before writing code, tell the user:
- Distinctive: line 184
Create new code based on the example, but adapted for:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Google Ads Code Samples Reference Skill
Purpose: Automatically reference official Google Ads API examples when building new functionality.
Type: Reference/efficiency skill (auto-invokes when implementing new Google Ads features)
Status: Production - Use before writing new Google Ads code
What This Skill Deliberately Does NOT Do
- Run the samples. It finds, explains, and adapts proven patterns (see the Instructions steps); executing the resulting code is yours to do.
- Write GAQL for you. Simple reporting queries belong to
gaql-query-patterns, not here. - Wrap mutations in approval. The samples show mutations; the two-step preview-and-approve gate is
mutation-safety. - Maintain or vet the samples. They are Google's official
google-ads-pythonexamples (cloned in Setup) — this skill indexes them, it doesn't own or warrant them.
Setup (One-Time)
This skill assumes you have a local checkout of Google's official Python samples repo at ./google-ads-python/:
git clone https://github.com/googleads/google-ads-python.gitAll paths below reference google-ads-python/examples/ relative to the project root. Adjust paths if you cloned elsewhere.
When to Auto-Invoke This Skill
Claude should invoke this skill automatically whenever user asks to:
- Build new Google Ads scripts (not ad-hoc queries)
- Implement new API operations (mutations, campaign creation, etc.)
- Work with unfamiliar Google Ads API features
- Create agents that interact with Google Ads API
- Solve Google Ads API errors (check examples for proper patterns)
Examples that trigger this skill:
- "Create a script to add Performance Max campaigns"
- "Build an agent to manage account-level negative keywords"
- "How do I batch create campaigns using the API?"
- "Write a script to update bidding strategies across accounts"
- "I'm getting an error with customer negative criteria - how should this work?"
DO NOT trigger for:
- Simple GAQL reporting queries (we already have patterns)
- Reading existing scripts
- Running existing workflows
Available Example Categories
We have 39 official Google example scripts organized by category:
Account Management (10 scripts)
Located: google-ads-python/examples/account_management/
Key examples:
get_account_hierarchy.py- MCC account traversallist_accessible_customers.py- Available customer accountsget_change_summary.py- Account change historyget_change_details.py- Detailed change trackingcreate_customer.py- Creating new accountslink_manager_to_client.py- MCC linkinginvite_user_with_access_role.py- User managementupdate_user_access.py- Permissions managementverify_advertiser_identity.py- Identity verification
Campaign Management (8 scripts)
Located: google-ads-python/examples/campaign_management/
Key examples:
add_complete_campaigns_using_batch_job.py- Bulk campaign creationget_all_disapproved_ads.py- Ad disapproval checkingvalidate_ad.py- Pre-flight ad validationadd_campaign_labels.py- Label managementcreate_experiment.py- Campaign experimentsset_ad_parameters.py- Dynamic ad parametersupdate_campaign_criterion_bid_modifier.py- Bid adjustments
Advanced Operations (19 scripts)
Located: google-ads-python/examples/advanced_operations/
Key examples:
add_performance_max_campaign.py- Performance Max setupadd_responsive_search_ad_full.py- RSAs with all assetsadd_smart_campaign.py- Smart campaignsadd_demand_gen_campaign.py- Demand Gen campaignsadd_dynamic_search_ads.py- DSA campaignscreate_and_attach_shared_keyword_set.py- Shared negative keywordsfind_and_remove_criteria_from_shared_set.py- Shared set managementuse_portfolio_bidding_strategy.py- Portfolio biddinguse_cross_account_bidding_strategy.py- Cross-account biddingadd_ad_group_bid_modifier.py- Bid modifiersget_ad_group_bid_modifiers.py- Reading bid modifiers
Reporting (2 scripts)
Located: google-ads-python/examples/reporting/
Key examples:
parallel_report_download.py- Efficient multi-account reporting
Instructions
When invoked, follow this protocol:
Step 1: Understand the User's Request
Parse what the user is asking for:
- Operation type: Create, read, update, delete?
- Resource type: Campaign, ad group, keyword, account setting?
- Scale: Single account or MCC-wide?
- Special features: Batch operations, mutations, reporting?
Step 2: Search Examples for Relevant Patterns
Based on the operation, search the appropriate category:
# For campaign/ad creation
ls google-ads-python/examples/campaign_management/
ls google-ads-python/examples/advanced_operations/
# For mutations and shared sets
grep -r "SharedSet" google-ads-python/examples/
grep -r "mutate" google-ads-python/examples/
# For account operations
ls google-ads-python/examples/account_management/
# For specific keywords
grep -r "CustomerNegativeCriterion" google-ads-python/examples/
grep -r "PerformanceMax" google-ads-python/examples/Step 3: Read the Most Relevant Example(s)
Once you identify 1-3 relevant examples, read them:
# Read the full example to understand the pattern
Read: google-ads-python/examples/advanced_operations/add_performance_max_campaign.pyPay attention to:
- Service client usage (e.g.,
client.get_service("CampaignService")) - Operation structure (e.g.,
CampaignOperation) - Field access patterns (e.g.,
operation.create.name = "...") - Error handling patterns
- Batch operation techniques
- Resource name construction
Step 4: Explain the Pattern to the User
Before writing code, tell the user:
I found a relevant example: add_performance_max_campaign.py
This shows the pattern for:
- Creating asset groups
- Setting up audience signals
- Linking to merchant center
- Batch creating all resources in one call
I'll adapt this pattern to your specific needs...Step 5: Adapt the Pattern
Create new code based on the example, but adapted for:
- User's specific account/campaign structure
- Our authentication (google-ads.yaml)
- Our safety systems (the mutation-safety skill if mutations)
- Our naming conventions
- Our error handling standards
Step 6: Reference the Source
In the new script, add a comment:
"""
Create Performance Max campaigns for property management accounts
Based on official example:
google-ads-python/examples/advanced_operations/add_performance_max_campaign.py
Adapted for:
- Example portfolio structure
- mutation-safety approval workflow
- CSV-driven batch creation
"""Example Workflow
User asks: "Create a script to add account-level negative keywords to multiple accounts"
Your process:
- Search for relevant examples:
grep -r "negative" google-ads-python/examples/advanced_operations/ grep -r "CustomerNegativeCriterion" google-ads-python/examples/ - Find:
create_and_attach_shared_keyword_set.py(closest match) - Read the example:
Read: google-ads-python/examples/advanced_operations/create_and_attach_shared_keyword_set.py - Explain to user:
"I found
create_and_attach_shared_keyword_set.pywhich shows how to create shared negative keyword sets. However, for TRUE account-level negatives (that appear in Account Settings), we needCustomerNegativeCriterionService, notSharedSetService. Let me check if there's a more specific example..." - Search more specifically:
grep -r "CustomerNegativeCriterion" google-ads-python/examples/ - If not found:
"The examples don't have a CustomerNegativeCriterion example, but the shared keyword pattern shows the proper structure for mutations. I'll adapt it using CustomerNegativeCriterionService based on the API docs..."
- Create the script using the shared keyword pattern as a template
Benefits of Using This Skill
Efficiency Gains
- 50-75% faster for complex operations (proven patterns vs trial/error)
- 25-40% faster for standard operations (better structure)
- Higher success rate on first attempt
Quality Improvements
- Proper error handling (examples include it)
- Correct service usage (no guessing)
- Best practices built-in (Google's own patterns)
- Fewer API errors (examples are tested)
Learning Effect
- Each example teaches Google's preferred patterns
- Builds knowledge for future implementations
- Reduces dependency on examples over time
Quick Reference: Example Index
For Creating Campaigns
- Performance Max:
advanced_operations/add_performance_max_campaign.py - Demand Gen:
advanced_operations/add_demand_gen_campaign.py - Smart:
advanced_operations/add_smart_campaign.py - Dynamic Search:
advanced_operations/add_dynamic_search_ads.py - Batch creation:
campaign_management/add_complete_campaigns_using_batch_job.py
For Mutations & Updates
- Shared negative keywords:
advanced_operations/create_and_attach_shared_keyword_set.py - Campaign labels:
campaign_management/add_campaign_labels.py - Bid modifiers:
advanced_operations/add_ad_group_bid_modifier.py
For Ads
- RSAs:
advanced_operations/add_responsive_search_ad_full.py - Call ads:
advanced_operations/add_call_ad.py - Display ads:
advanced_operations/add_display_upload_ad.py - Ad validation:
campaign_management/validate_ad.py - Disapprovals:
campaign_management/get_all_disapproved_ads.py
For Account Management
- Account hierarchy:
account_management/get_account_hierarchy.py - List accounts:
account_management/list_accessible_customers.py - Change history:
account_management/get_change_summary.py+get_change_details.py - Create accounts:
account_management/create_customer.py - User access:
account_management/invite_user_with_access_role.py
For Bidding Strategies
- Portfolio bidding:
advanced_operations/use_portfolio_bidding_strategy.py - Cross-account bidding:
advanced_operations/use_cross_account_bidding_strategy.py
For Reporting
- Multi-account reports:
reporting/parallel_report_download.py
When NOT to Use This Skill
Skip this skill when:
- Writing simple GAQL queries (the gaql-query-patterns skill covers these)
- Reading/debugging existing scripts
- Running existing agents
- Making minor modifications to working code
When to Load Other Skills
| Skill | When |
mutation-safety | When a sample performs a mutation — its two-step approval wraps the change before it runs |
fair-housing-compliance | When a sample sets targeting for a housing account — compliance constrains what's allowed |
client-communication-standards | When a reporting sample's output becomes a client-facing deliverable |
Success Criteria
This skill is successful when:
- ✅ Relevant example found before writing custom code
- ✅ Example pattern explained to user
- ✅ New code adapted from proven pattern
- ✅ Source example referenced in comments
- ✅ Time saved vs writing from scratch
- ✅ Fewer API errors due to proper structure
Related Documentation
- Links to official Google Ads API docs — see developers.google.com/google-ads/api/docs
- google-ads-python/examples/README.md - Safety warnings and usage guide
- GitHub: https://github.com/googleads/google-ads-python
- Samples index: https://developers.google.com/google-ads/api/samples
Created: 2025-10-28 Status: Production - Auto-invoke for new Google Ads development Trigger: User requests new Google Ads scripts/agents/functionality
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

