Work Pricing FAQ Blog Jobs Trending Book the AI Audit

HomeBlogAutomate LinkedIn Ads Reporting with Claude Code (Real Setup)

Automate LinkedIn Ads Reporting with Claude Code (Real Setup)

LinkedIn Ads reporting is one of those tasks that feels like it should take 20 minutes but always stretches into two hours. You log into Campaign Manager, export CSVs for each account, copy metrics into a spreadsheet, calculate CTR and cost-per-lead manually, write a summary of what worked and what didn't, paste it into an email, and send it off. If you're running campaigns for more than two clients, that's half a day every week.

I automate LinkedIn Ads reporting with Claude Code, and it's saved me around four hours a week since I set it up. The system pulls campaign data via the LinkedIn Marketing API, formats it into a clean client-ready report, flags any performance anomalies, and either emails the report or drops it into a shared folder. Here's exactly how I built it and how you can do the same.

Why Automate LinkedIn Ads Reporting with Claude Code

LinkedIn's native reporting is fine for quick checks, but it's not built for client deliverables. You can't schedule reports to auto-send. The CSV exports are messy. And if you manage multiple ad accounts, switching between them is a time sink.

Most agencies solve this by hiring a junior to do it manually or by using a third-party dashboard tool that costs $200–$500 per month. Both options work, but they're overkill if you just need a clean weekly report with campaign performance, spend pacing, and a few written observations.

Claude Code can handle the entire workflow: API authentication, data retrieval, metric calculation, report generation, and delivery. Once it's set up, the only manual step is reviewing the output before it goes to the client — and even that becomes optional once you trust the system.

What the LinkedIn Ads Reporting Workflow Does

The workflow I built has four main steps:

  • Pull campaign data — authenticate with the LinkedIn Marketing API, fetch impressions, clicks, spend, conversions, and any custom conversion events you're tracking
  • Calculate key metrics — CTR, CPC, CPM, cost per lead, conversion rate, and compare week-over-week or month-over-month depending on the reporting cadence
  • Generate a written summary — Claude Code writes 2–3 paragraphs highlighting top performers, underperformers, and any budget pacing issues
  • Format and send — output gets formatted as a PDF or HTML email and either auto-sends via SMTP or gets saved to a shared Google Drive folder

The entire process runs on a schedule — I have mine set to run every Monday morning at 8 a.m. Pacific. By the time I check email, the reports are already queued or sent.

Setting Up LinkedIn Marketing API Access

Before Claude Code can pull any data, you need API credentials. LinkedIn's developer process is more locked-down than Google or Meta, but it's not hard if you follow the steps.

First, create a LinkedIn app through the LinkedIn Developer Portal. You'll need to associate it with a LinkedIn Company Page — if you don't have one, create a basic page for your agency or consulting business. Request access to the Marketing Developer Platform product; approval usually takes 1–3 business days.

Once approved, generate an access token. LinkedIn uses OAuth 2.0, so you'll need to build a small authentication flow or use a pre-built library. I use the linkedin-api Python package, which simplifies the token exchange. Store your client ID, client secret, and refresh token in environment variables — never hardcode credentials.

If you're managing ads for multiple clients, you'll need separate tokens for each ad account. LinkedIn ties API access to the account owner's permissions, so make sure you have admin or analyst access before requesting a token.

Building the Data Pull Script

The core of the automation is a Python script that calls the LinkedIn Ads API and retrieves campaign performance data. The endpoint you want is /adAnalytics, which returns metrics aggregated by campaign, ad group, or creative.

Here's the basic structure of the script I use:

import requests
import os
from datetime import datetime, timedelta

# Set date range (last 7 days)
end_date = datetime.now()
start_date = end_date - timedelta(days=7)

# LinkedIn API endpoint
url = "https://api.linkedin.com/v2/adAnalytics"
headers = {
    "Authorization": f"Bearer {os.getenv('LINKEDIN_ACCESS_TOKEN')}",
    "Content-Type": "application/json"
}

# Query parameters
params = {
    "q": "analytics",
    "pivot": "CAMPAIGN",
    "dateRange.start.day": start_date.day,
    "dateRange.start.month": start_date.month,
    "dateRange.start.year": start_date.year,
    "dateRange.end.day": end_date.day,
    "dateRange.end.month": end_date.month,
    "dateRange.end.year": end_date.year,
    "accounts": f"urn:li:sponsoredAccount:{os.getenv('ACCOUNT_ID')}",
    "fields": "impressions,clicks,costInLocalCurrency,externalWebsiteConversions"
}

response = requests.get(url, headers=headers, params=params)
data = response.json()

# Process and store data
campaigns = data.get("elements", [])
for campaign in campaigns:
    print(campaign)

This script pulls the last seven days of data for a single ad account. You can adjust the date range, add filters for specific campaigns, or pivot by ad creative instead of campaign. The API returns JSON, which you can parse and load into a pandas DataFrame for easier manipulation.

Calculating Metrics and Flagging Anomalies

Raw API data is just numbers. The value comes from turning those numbers into insights. I calculate standard PPC metrics — CTR, CPC, CPM, cost per conversion — and compare them against the previous period to flag any significant changes.

For example, if CTR drops by more than 20% week-over-week, the script flags it and includes a note in the report. Same for sudden spend spikes or campaigns that hit their daily budget cap too early in the day. These flags save me from having to manually scan every campaign for issues.

The logic looks something like this:

# Calculate CTR
campaign["ctr"] = (campaign["clicks"] / campaign["impressions"]) * 100 if campaign["impressions"] > 0 else 0

# Compare to previous week
previous_ctr = get_previous_week_ctr(campaign["id"])  # fetch from stored data
if campaign["ctr"] < previous_ctr * 0.8:
    campaign["alert"] = "CTR down 20%+ vs last week"

I store historical data in a lightweight SQLite database so I can run these comparisons without re-fetching old data from the API every time.

Generating the Written Summary with Claude Code

Numbers alone don't make a good client report. You need context. This is where Claude Code shines — it can read the metrics, identify patterns, and write a coherent summary in plain English.

I pass the processed campaign data to Claude Code along with a prompt that looks like this:

You are a PPC analyst. Based on the following LinkedIn Ads data for the past 7 days, write a 2-3 paragraph summary for the client. Highlight:
1. Top-performing campaigns (highest CTR or lowest cost per lead)
2. Any campaigns underperforming or spending inefficiently
3. Recommendations for budget reallocation or creative refresh

Data:
{campaign_data_json}

Write in a professional but conversational tone. Be specific with numbers.

Claude Code returns a summary that sounds like it came from an experienced analyst. I review it for accuracy, make minor edits if needed, and include it at the top of the PDF report.

Formatting and Delivering the Report

The final step is turning the data and summary into a client-ready deliverable. I use a simple HTML template that includes:

  • Executive summary (the Claude-generated text)
  • Performance table with key metrics by campaign
  • Week-over-week comparison chart
  • Budget pacing overview

I convert the HTML to PDF using a library like weasyprint or pdfkit, then either email it via an SMTP connection or save it to a Google Drive folder that the client has access to.

For email delivery, I use a Gmail account with app-specific passwords and send the report using Python's smtplib. The email subject line is dynamic and includes the date range: "LinkedIn Ads Report – Aug 8–14, 2026."

What This Saves You

Before automation, I spent 60–90 minutes per client per week on LinkedIn Ads reporting. With three active PPC clients, that was 3–4.5 hours every Monday. Now the entire process takes about 20 minutes — just enough time to review the reports and make sure nothing looks off before they go out.

The system also catches issues faster. If a campaign's CTR tanks or spend accelerates unexpectedly, I get a flagged alert on Monday morning instead of discovering it when the client asks why their budget ran out early. That alone has saved more than one awkward conversation.

Getting Started with Your Own LinkedIn Ads Automation

If you want to build this for your own agency or client roster, here's the fastest path:

  • Set up LinkedIn Marketing API access for each ad account you manage
  • Build the data pull script first — make sure you can reliably fetch campaign metrics before adding any automation
  • Start with a simple report format (just a CSV or plain-text summary) and iterate from there
  • Add the Claude Code summary layer once you're confident in the data pipeline
  • Schedule the script to run weekly using cron (Linux/Mac) or Task Scheduler (Windows)

The whole setup took me an afternoon to build the first working version and another two hours to refine the report format and add the anomaly detection logic. If you already have some Python experience, you can replicate this in a day.

For more on how I use Claude Code to automate client workflows, check out my posts on Facebook Ads reporting automation and Google Ads automation with Claude Code. And if you have questions about setting this up for your specific stack, the FAQ page covers a lot of the common technical blockers.

The tools are here. The API access is straightforward. The only question is whether you'd rather spend Monday mornings writing reports or doing higher-value work.

Work with me

Want this kind of result for your business?

Start with the AI Audit — $1,500. One focused engagement. The 3 highest-ROI opportunities in your business, ranked. A working proof-of-concept of the #1. Credited toward your build if we go forward.

Book the AI Audit → Read the FAQ
← All posts Book the AI Audit →