Service path
AI search optimization
See how answer-engine visibility fits into the broader law firm SEO system.
View the AI-search layerHow we built an AI system using the Claude API and Google Ads API to automate campaign setup for law firms. Architecture, prompts, failure modes, and real costs.
Reading path
The firms that benefit most from AI search and automation are usually the same firms with better structure, stronger content, and clearer entity signals underneath.
Setting up a Google Ads campaign for a law firm takes 4-6 hours of skilled work. Keyword research, match type decisions, negative keyword lists, ad group structure, ad copy variations, location targeting, bid strategy selection, conversion tracking configuration. Multiply that by 20 new clients a month and you have a full-time employee doing nothing but campaign setup.
We built a system that does the first 80% of that work automatically, using the Claude API for the thinking and the Google Ads API for the execution. A human still reviews everything before it goes live. Nothing runs without approval.
Here is how it works, what broke along the way, and where we landed.
Legal marketing agencies hit a scaling wall around 100 clients. The work is repetitive but not simple. Every personal injury firm in Miami needs similar keywords, but the specific mix depends on their practice areas, case types they want, geographic coverage, and budget. A family law firm in Denver has a completely different keyword universe.
The setup process follows a pattern, but the pattern has enough variation that you cannot just copy-paste a template. You need someone who understands both Google Ads and the legal vertical to make judgment calls about which keywords to include, how to structure ad groups, and what the ad copy should say.
That is exactly the kind of work that AI handles well. It is pattern-based with structured variation. The inputs are predictable (practice areas, location, budget, case types). The output is structured data (keyword lists, ad group hierarchies, ad copy). And the quality bar is “good enough for a human to review and approve”, not “perfect on the first try.”
The system has three stages. Each stage produces structured output that feeds into the next. A human checkpoint sits between stage 2 and stage 3.
Stage 1: Client intake processing. A structured form captures the inputs: firm name, practice areas, target locations (cities, counties, radius), monthly budget, case types they want (and do not want), existing campaigns (if migrating), and any specific messaging requirements.
This data goes into a JSON document. No AI is involved in this stage. It is just data collection and normalization.
Stage 2: Campaign generation. This is where Claude does the work. The system sends the client intake JSON to the Claude API with a detailed system prompt that specifies exactly what to produce.
The prompt is not “create a Google Ads campaign.” That would produce garbage. The prompt is closer to 2,000 words of specific instructions covering:
Claude returns a structured JSON response. Not freeform text. We use tool_use to force the output into a defined schema:
{
"campaigns": [
{
"name": "PI | Miami-Dade | High Intent",
"budget_daily_micros": 85000000,
"location_targets": ["Miami, FL", "Miami Beach, FL", "Coral Gables, FL"],
"ad_groups": [
{
"name": "Car Accident Attorney",
"keywords": [
{ "text": "car accident attorney miami", "match_type": "EXACT" },
{ "text": "auto accident lawyer near me", "match_type": "PHRASE" },
{ "text": "car crash lawyer miami dade", "match_type": "EXACT" }
],
"ads": [
{
"headlines": [
"Miami Car Accident Attorney",
"No Fee Unless You Win",
"Free Case Review Today"
],
"descriptions": [
"Injured in a car accident? Our Miami attorneys have recovered $50M+ for clients. Call now.",
"Trusted Miami car accident lawyers. Free consultation. No upfront fees."
]
}
]
}
],
"negative_keywords": [
"free legal advice", "pro bono", "lawyer salary",
"how to become a lawyer", "law school", "legal forms",
"cheap lawyer", "lawyer jokes"
]
}
]
}
The schema is strict. Every field has a type. Keywords have match types. Budgets are in micros (one million micros equals one currency unit, which is how the Google Ads API represents money). Headlines respect the 30-character limit. Descriptions respect the 90-character limit.
Stage 3: Human review and deployment. The generated campaign structure goes into a review interface. A human sees every keyword, every ad, every budget allocation. They can approve, modify, or reject any piece.
Only after approval does the system touch the Google Ads API. It creates the campaigns, ad groups, keywords, and ads exactly as approved. Conversion tracking and bid strategies are configured based on the client’s goals (maximize conversions for lead gen, target CPA if there is enough historical data).
The first version of the system prompt was 400 words. It produced campaigns that looked reasonable at a glance but fell apart on review. Common failures:
Each failure mode got a specific instruction added to the prompt. The prompt grew from 400 words to 2,000 words over about three weeks of iteration.
The critical insight was that the prompt needs to encode the same decision-making heuristics that an experienced Google Ads manager carries in their head. “Use exact match for high-intent keywords” is not enough. You need to define what “high-intent” means in a legal context: keywords that contain “attorney”, “lawyer”, “law firm”, “hire”, “consultation”, or “near me” combined with a practice area. You need to say that “car accident” alone is informational, but “car accident attorney” is high-intent.
We version the prompts. Each version is a file with a timestamp and a changelog comment at the top. When we update a prompt, the old version stays. We can A/B test by routing some clients to the new version and comparing the review-rejection rate. If the new prompt produces campaigns that humans approve with fewer modifications, it is better.
Problem 1: Claude sometimes invented keywords. Early versions would generate keywords that sounded plausible but had zero search volume. “Automobile collision litigation specialist” is not something anyone types into Google. The fix was adding explicit instructions: generate keywords based on how people actually search, not how lawyers describe their services. Use plain language. Short phrases. The way someone would talk to a friend: “car accident lawyer miami”, not “vehicular collision attorney Miami-Dade County.”
Problem 2: Budget math did not add up. Claude would allocate 60% of the budget to personal injury, 30% to family law, and 25% to criminal defense. That is 115%. The fix was switching from percentage-based allocation to absolute amounts and adding a validation step that checks the sum before the output is accepted. If the sum does not match the total budget, the system retries with an explicit correction.
Problem 3: Headline character limits. Google Ads headlines have a strict 30-character limit. Claude would generate headlines like “Experienced Personal Injury Attorney” (36 characters) regularly. We added character counting to the tool schema validation. If a headline exceeds 30 characters, the tool call fails with an error message that includes the character count and asks for a shorter version. Claude corrects it on the retry.
Problem 4: Location targeting ambiguity. “Miami” could mean the city of Miami, Miami-Dade County, or the Miami metro area. These produce very different targeting in Google Ads. We now require the intake form to specify exact city names and zip codes, and the prompt explicitly instructs Claude to use only the provided locations, never to infer or expand the targeting area.
The Google Ads API is not simple. Authentication alone requires OAuth2 with a developer token, a client ID, a client secret, a refresh token, and a login customer ID. Rate limits are real. Error messages are often unhelpful.
A few things we learned:
Before the system: 4-6 hours of skilled work per campaign setup. At $75/hour loaded cost for a competent Google Ads specialist, that is $300-450 per client.
After the system: 10 minutes of compute time (Claude API calls are a few cents) plus 30-45 minutes of human review. Total cost is roughly $45-60 per client.
At 20 new clients per month, that is a savings of $5,000-8,000 monthly. The system paid for its development time within the first month.
The real benefit is not cost savings. It is consistency. Human-built campaigns vary in quality depending on who builds them, what time of day it is, and how many campaigns they have already set up that week. The AI system produces the same quality every time, and the human review catches the same categories of issues every time because the reviewers use a standardized checklist.
There are no orchestration frameworks. No LangChain, no LangGraph, no CrewAI. The workflow is three functions called in sequence with a database write between each step. Adding a framework for a linear three-step process would be overhead with no benefit.
If the workflow had branching logic, parallel agents, or dynamic tool selection, a framework might make sense. This one does not. It is a pipeline. Pipelines do not need orchestration frameworks.
If you are a legal marketing agency looking at automating campaign setup, here is what matters:
The goal is not full automation. It is removing the repetitive work so your team spends their time on judgment calls instead of data entry.
Need a clearer next move?
We'll audit your current Google Ads setup, identify wasted spend, and show you how automated campaign generation compares to your existing workflow.
Next steps
Keep this topic grounded by moving into the AI-search guide, the service layer that supports citation readiness, or the broader research on how law firms are adapting.
Service path
See how answer-engine visibility fits into the broader law firm SEO system.
View the AI-search layerGuide path
Read the complete guide to AI-assisted legal discovery, citations, and generative search behavior.
Read the guideResearch path
Use the research report to ground AI discussions in wider legal marketing benchmarks.
Read the researchAI & Automation
Automate your law firm's SEO and marketing with AI. Reporting, content workflows, lead nurturing, and rank tracking with real ROI data. Learn more!
Read the articleAI & Legal Tech
AI search is replacing traditional Google results for legal queries. Learn how 41% of searches now touch AI and what your firm must do to stay visible. Book a call!
Read the articleAI & Automation
Deploy AI chatbots at your firm the right way. ABA Opinion 512, UPL risks, CCPA rules, and practical safeguards covered. Get your compliance checklist!
Read the articleFrequently asked questions
Quick answers to the most common questions about this topic.
01
Yes, but not fully. We built a system that automates roughly 80% of the setup work: keyword research, match type selection, ad group structure, ad copy generation, negative keyword lists, location targeting, and budget allocation. A human reviews everything before it goes live. The AI handles the labor-intensive parts. The human provides the strategic judgment. Nothing touches a client's Google Ads account without approval.
02
The system sends client intake data (practice areas, locations, budget, case types) to the Claude API with a detailed 2,000-word system prompt that encodes Google Ads best practices specific to legal marketing. Claude returns structured JSON output using tool_use (function calling), not freeform text. The JSON conforms to a strict schema that maps directly to the Google Ads API data model, with fields for campaigns, ad groups, keywords with match types, ad copy with character limits, and budget allocations in micros.
03
Each campaign generation costs roughly $0.25 in Claude API usage. A human spends 30-45 minutes reviewing and refining the output, compared to 4-6 hours building from scratch. At 20 new clients per month, the system saves $5,000-8,000 monthly in specialist time. The orchestration layer runs on one VPS at $40/month, with database hosting and API usage as separate line items.
04
Three safeguards. First, the system prompt explicitly instructs Claude to generate keywords based on how people actually search, not how lawyers describe their services. Second, we use tool_use with strict schema validation that rejects outputs with wrong types or missing fields. Third, every generated campaign goes through human review before anything is created in Google Ads. About 5% of outputs need meaningful adjustments.
05
The four most common failures we encountered: Claude inventing plausible-sounding keywords with zero search volume, budget allocations that add up to more than 100%, headlines exceeding the 30-character limit, and location targeting ambiguity where a city name could refer to a city, county, or metro area. Each failure mode got a specific programmatic validation check and prompt instruction to prevent recurrence.
06
For a linear pipeline like campaign setup, no. Our system is three functions called in sequence with a database write between each step. Adding an orchestration framework for a sequential process adds complexity without solving any real problem. If your workflow had branching logic, parallel agents, or dynamic tool selection, a framework might make sense. A pipeline does not need an orchestration framework.
07
Batch operations. The Google Ads API mutate endpoint accepts batches of up to 5,000 operations in a single request. We batch all keywords for an ad group into one request instead of creating them one at a time. We also validate all field values locally before sending API calls, which eliminates most error-retry cycles that would otherwise consume rate limit quota.
08
The prompt needs to encode the same decision-making heuristics an experienced Google Ads manager carries. Saying 'use exact match for high-intent keywords' is not enough. You need to define what high-intent means in a legal context: keywords containing attorney, lawyer, law firm, hire, consultation, or near me combined with a practice area. You need to specify that 'car accident' alone is informational but 'car accident attorney' is high-intent. Every rule of thumb goes in the prompt.
Next step
Book a free strategy session. We'll show you how AI-powered campaign setup works, review your current campaigns, and identify where automation can save your team time.