AI

ROAS, conversion rate and CAC with an AI agent: store, GA4 and ads

Google Analytics MCP, Meta Ads MCP and Google Ads MCP: how Claude combines your store, GA4 and ad spend into one report for ROAS, CAC and conversion.

The CloudCart team15 min read
Three small windows with store orders, analytics and ad data, connected by lines to one chat where a summary table of numbers is forming
In this article · 12 sections
  1. Where each number in a ROAS, conversion and CAC report comes from
  2. What the AI agent reads from CloudCart with a read-only key
  3. How to connect Google Analytics 4 to Claude: the Google Analytics MCP server
  4. How to connect Google Ads to an AI agent
  5. How to connect Meta Ads to Claude: the official Ads MCP server
  6. No connector: the manual export that works today
  7. ROAS, CAC and conversion rate formulas for the report
  8. Why your store, GA4 and Meta show different revenue
  9. The weekly marketing report: template and prompt for the agent
  10. Ready-made prompts for ROAS, CAC and conversion rate
  11. Common mistakes in an AI ad report
  12. Frequently asked questions

In short: an AI agent such as Claude calculates ROAS, conversion rate and CAC once it can read three places. It takes orders, customers and Analytics reports from CloudCart with a read-only PAT token, sessions from Google Analytics 4 through the Google Analytics MCP server, and ad spend from Meta Ads and Google Ads through their MCP servers or a CSV export.

This guide continues Ecommerce KPIs: 10 metrics an AI agent can calculate for you and connects your analytics and ad accounts to the same agent. It works the same for a store selling in Germany, Austria, Poland or across the EU.

Where each number in a ROAS, conversion and CAC report comes from

Each of the three metrics has its numerator and denominator in different systems: the money is in your store, the visits are in analytics, and the spend is in the ad account.

NumberCloudCart (PAT token)Google Analytics 4Meta Ads / Google Ads
Revenue, orders, average order valueYes, the exact order totalsApproximate, from the purchase event in the browserConversion value by the platform's own rules
New and returning customersYes, from order historyfirstTimePurchasers, per GA4 userNo
SessionsYes, the Total Visits report in AnalyticsYes, sessionsClicks, not sessions
Conversion rateYes, the conversion rate report in AnalyticsYes, orders ÷ sessionsOnly for traffic from the ads
Revenue by channelYes, Sales by traffic source and UTM on ordersYes, by channel and by source / mediumOnly its own channel
Ad spendNoOnly from a linked Google Ads account or imported cost dataYes

The rule for the whole report: count money from the store, spend from the ad account, and use GA4 to explain how visitors behave.

What the AI agent reads from CloudCart with a read-only key

The AI agent reads orders, products, customers, discounts and the Analytics dashboard reports from CloudCart through the Admin API, using a PAT (Personal Access Token) that the store owner creates under Settings → PAT Tokens. A Read Only token views everything and changes nothing.

The detail that matters for this report: the CloudCart Admin API also has a query for Analytics reports (analyticsReport). It returns every dashboard card as a table for a chosen period. So the agent gets sessions (online-store-sessions), conversion rate (cart-conversion-rate) and revenue by channel (sales-by-traffic-source) from the store itself, without GA4.

  • CloudCart counts sessions its own way. A visitor browsing for 2 hours is 2 sessions, and switching from desktop to mobile also starts a new session. That is why the number in Analytics differs from sessions in GA4, and the two never go into the same formula.
  • Session data is not real time. A visit shows up in Analytics 1 to 2 hours later, while a new order appears in the order list immediately.
  • Revenue by channel follows the first visit. The store recognises an ad click by gclid and gad_source (Google Ads), fbclid (Meta Ads) and ttclid (TikTok Ads), and the UTM source, medium and campaign are saved on the order. UTM tracking is included in CC Pro and CC Master, see /pricing.
  • The numbers follow the order statuses chosen in the Analytics settings. Give the agent the same rule.
  • One store per country means one report per store. A separate store per market, with its own language and currency, has its own Analytics and key. Ask for one table per store and a total in euro.

How to create the token step by step is on Store with an AI assistant.

How to connect Google Analytics 4 to Claude: the Google Analytics MCP server

Google Analytics 4 connects to Claude Code or Gemini CLI through the Google Analytics MCP server, an open-source project from the Google Analytics organisation on GitHub. It runs on your computer (or as a remote HTTP service), reads GA4 through the Admin API and the Data API, and is read-only by default (google-analytics-mcp on GitHub).

The server gives the agent reports (run_report), funnels (run_funnel_report) and realtime data. Write tools need the --allow-write flag and the analytics.edit scope.

  1. Connect GA4 to your store. In the CloudCart admin open Apps → Google Analytics, paste the Measurement ID (it starts with G-) and activate the app. The store then sends view_item, add_to_cart, begin_checkout, purchase and the other standard ecommerce events itself. Details: GA4 and Google Tag Manager for an online store.
  2. Prepare a Google Cloud project. Enable the Google Analytics Admin API and the Google Analytics Data API in it.
  3. Grant read-only access. gcloud auth application-default login creates a credentials file for your Google account with the analytics.readonly scope. The command prints the path to the file.
  4. Add the server to Claude Code. The README command is claude mcp add analytics-mcp --scope user with two environment variables: the path to the credentials file and your Google Cloud project ID. For Gemini CLI the same goes into ~/.gemini/settings.json.
  5. Test it. Ask for "sessions and purchases for the last 7 days" and compare with GA4.

Important: this is a technical setup with Google Cloud and a terminal. The agent walks you through it, but you sign in to Google yourself. Otherwise use the manual export below.

What GA4 adds to the report, and what it doesn't

GA4 adds behaviour data: sessions, channels by sessionDefaultChannelGroup, sessionSourceMedium and the funnel to purchase. If Google Ads is linked to the property or you import cost data, GA4 also has advertiserAdCost and returnOnAdSpend. Meta spend does not reach GA4 on its own.

Two CloudCart rules explain why GA4 revenue is lower than store revenue. First, consent: EU rules allow analytics cookies only after the visitor agrees (Article 5(3) of the ePrivacy Directive on EUR-Lex). With the cookie app and its "Google Consent Mode" group active, the store sends Google Consent Mode v2 signals and every signal starts as denied until the visitor accepts. Second, the store does not send a refund event, so returned orders stay in GA4 revenue. With the EU 14-day right of withdrawal, only the store sees the money that comes back.

Google Ads connects to an AI agent through the Google Ads MCP server, an open-source project from the Google Ads organisation on GitHub. It reads campaigns with GAQL queries and can change only labels and assets, always with a dry run and a confirmation before anything is written (google-ads-mcp on GitHub).

  1. Enable the Google Ads API in a Google Cloud project; the one you use for GA4 works.
  2. Request access to real accounts. Developer tokens were retired on September 9, 2026, and access now comes from the Google Cloud project. Test access only reaches test accounts, so apply for Explorer access in the Cloud Console. Explorer is usually approved automatically and allows up to 2,880 operations per day on production accounts (Google Ads API, access levels).
  3. Set up credentials with the adwords scope, the same way as for GA4, or with an OAuth client.
  4. Turn off writing if you only need reports. In tools_config.yaml set labels: false and assets: false, which makes the server read-only.
  5. Add the server to your client's MCP settings (for Claude Code: ~/.claude/settings.json).

If Google Ads is linked to GA4, spend also arrives through the Google Analytics MCP server. Campaign structure is covered in Google Ads for an online store.

How to connect Meta Ads to Claude: the official Ads MCP server

Meta Ads connects to an AI agent through Meta's official Ads MCP server at https://mcp.facebook.com/ads. Since July 16, 2026 it is open to every developer with their own Meta app, and it returns spend, impressions, CTR and ROAS by date range, age, gender and platform (Meta for Developers announcement).

  1. Sign in with OAuth through Facebook Login for Business, with the profile that has access to the ad account. You need the App ID of your own Meta app.
  2. Add the server to Claude Code. Meta's documentation gives the command claude mcp add --transport http --client-id <META_APP_ID> meta-ads https://mcp.facebook.com/ads (Ads MCP Server: Get started).
  3. Grant the minimum permissions. You need ads_mcp_management and ads_read. For a report, do not grant ads_management, because the server can also create, edit and delete campaigns.

Important: Meta documents Claude Code (the command above) and ChatGPT (OAuth, same server URL). For other assistants, check Meta's page first. Campaign setup is in the guide to Meta ads.

No connector: the manual export that works today

Without an MCP server, the report is just as accurate if you give the agent your spend as a file. Only the store needs a direct connection.

  1. Meta Ads Manager. Choose the period and the columns amount spent, purchases and purchase value, then export the report as CSV.
  2. Google Ads. In the campaigns report choose the same period and download a CSV with cost, clicks and conversions.
  3. Give the files to the agent with the prompt from the weekly report section. The agent matches them by channel and adds orders from CloudCart.

Or just type the numbers: "Last week Meta €420, Google €180."

ROAS, CAC and conversion rate formulas for the report

ROAS is ad revenue divided by ad spend; CAC is ad spend divided by new customers; conversion rate is orders divided by sessions, times 100. All three use the same period and the same order status rule.

MetricFormulaNumerator fromDenominator fromExample
ROAS by channelChannel revenue ÷ channel spendCloudCart: sales by source or UTMMeta Ads / Google Ads€2,520 ÷ €600 = 4.2
Blended ROAS, or MER (Marketing Efficiency Ratio)Total revenue ÷ total ad spendCloudCart: all ordersSum of the ad accounts€7,800 ÷ €900 = 8.7
CACAd spend ÷ new customersThe ad accountsCloudCart: new customers€900 ÷ 60 = €15
Conversion rateOrders ÷ sessions × 100CloudCart: ordersAnalytics or GA4, one source only120 ÷ 6,000 = 2%
Break-even ROAS1 ÷ marginMargin after product cost and shipping-1 ÷ 0.25 = 4

Compare revenue excluding VAT with spend excluding VAT, because VAT rates differ by EU country and gross revenue inflates ROAS. How to set a target ROAS from your margin, and when ROI says more than ROAS, is in the guide to ROAS and ROI for an online store.

If ROAS by channel rises while blended ROAS falls, the channels are claiming the same orders.

Why your store, GA4 and Meta show different revenue

Revenue for the same week almost never matches, because CloudCart counts actual orders, GA4 counts purchase events from the browser, and the ad platforms count conversions within their own attribution window.

  • GA4 misses visitors who refused cookies or block ads, and keeps returned orders in revenue because the store sends no refund event.
  • Meta and Google Ads credit a purchase to an ad the person saw or clicked days earlier, by their own rules. The same order can appear in both platforms.
  • Several currencies make it worse: if one store sells in euro and another in złoty or koruna, ask the agent to convert everything to one currency at one rate before dividing.

Platform numbers are for decisions inside the platform, such as which ad to pause. For the budget, money and new customers come from CloudCart.

The weekly marketing report: template and prompt for the agent

The weekly report is a 10-row table: what ads brought in, what they cost, and where the problem is.

RowSourceSignal to act
Revenue, orders, average order valueCloudCart, ordersDown more than 10% on last week
New customersCloudCart, customersFalling while spend stays the same
Sessions and conversion rateCloudCart Analytics or GA4Conversion falls at the same sessions
Meta Ads spendMeta Ads MCP or CSVAbove the weekly budget
Google Ads spendGoogle Ads MCP, GA4 or CSVAbove the weekly budget
Revenue by channelCloudCart, sales by source and UTMA channel with spend and no orders
ROAS by channelCloudCart revenue ÷ spendBelow break-even ROAS
Blended ROAS (MER)All revenue ÷ all spendDown 2 weeks in a row
CACSpend ÷ new customersAbove the profit on a first order
Top 5 products from adsCloudCart, orders with a paid sourceA product with low stock

The prompt for the agent when the MCP servers are connected:

Build the weekly marketing report for the last 7 days against the previous 7.
Take revenue (excluding VAT), orders, average order value and new customers
from CloudCart, counting paid, completed and fulfilled orders. Take sessions
and conversion rate from CloudCart Analytics. Take spend from Meta Ads and
Google Ads. Revenue by channel comes from "Sales by traffic source" in
CloudCart, not from the platforms. Calculate ROAS by channel, blended ROAS
and CAC. Our margin is 30%. Flag every channel below break-even ROAS and
every number down more than 10%, with one action each.
Read only, change nothing.

If the ad servers aren't connected, replace the spend sentence with "Spend is in the files I'm attaching" or with the numbers. How to get the report automatically every morning on a schedule in Claude Code, Codex or Gemini CLI is in the guide to an 8 a.m. sales report with an AI agent.

Ready-made prompts for ROAS, CAC and conversion rate

Each prompt names the source of every number, so the agent never mixes platform revenue with store revenue.

QuestionPrompt for the agent
ROAS by channel"Calculate ROAS for Meta and Google for October: revenue from sales by traffic source in CloudCart, spend from the ad accounts."
CAC by month"Give me CAC for the last 3 months by month: total ad spend ÷ new customers in CloudCart."
Conversion rate by channel"From GA4, give me sessions by channel for 30 days, from CloudCart the orders for the same channels, and calculate conversion rate for each."
Losing campaigns"Which Meta and Google campaigns spent over €50 in 14 days and have fewer than 1 order in CloudCart with their UTM?"
Funnel"From GA4, give me the product → cart → checkout → purchase funnel for mobile and desktop for the last 30 days. Where is the biggest drop?"
By country"For each of my stores, give revenue, spend and ROAS for the month, converted to euro, and name the market that only costs ad spend."

The prompts work in Claude Code, ChatGPT Codex and Gemini CLI. For Claude Code there is a plugin with CloudCart skills, described on CloudCart in Claude Code.

Common mistakes in an AI ad report

  • Sessions from two systems in one formula. Orders ÷ GA4 sessions and orders ÷ Analytics sessions give different conversion rates. Pick one system and stick with it.
  • Different periods. Spend for the whole month and orders up to the 25th lower ROAS. Use the same dates everywhere.
  • Ads without UTM tags. Without UTM tags the store still recognises an ad click by gclid and fbclid, but the campaign isn't visible on the order. Put utm_campaign on every ad.

CloudCart, the ecommerce platform with 0% commission on sales, gives the AI agent orders, customers and Analytics reports with one read-only key, while ads and GA4 join through MCP servers or a weekly CSV. Card payments through CloudCart Pay have a 0% transaction fee until the end of 2026. Plan prices are on /pricing (billed annually, excluding VAT, from €14/month for Baby Pack). Create a store for €1 and run your first ad report this week. Questions: support@cloudcart.com.

Frequently asked questions

Yes. Google Analytics MCP is an open-source server from the Google Analytics organisation on GitHub that gives Claude Code and Gemini CLI read-only access to GA4. Setup needs a Google Cloud project and the analytics.readonly scope.

Yes. Meta runs an Ads MCP server at mcp.facebook.com/ads, open to developers with their own Meta app since July 2026. It returns spend, CTR and ROAS by period and breakdown; for reports, grant ads_read and not ads_management.

Through the open-source Google Ads MCP server: enable the Google Ads API in a Google Cloud project, request Explorer access, sign in with the adwords scope and add the server to your client. With labels and assets turned off in tools_config.yaml, it only reads.

Yes. With a read-only PAT token the agent reads CloudCart Analytics through the Admin API, including sessions, conversion rate and sales by traffic source.

GA4 only sees visitors who accepted analytics cookies and don't block tracking, and it counts purchase events from the browser. The store counts every order, so for ROAS and CAC always use store revenue.

For reporting, give read-only access only: a Read Only PAT token, analytics.readonly for GA4, ads_read for Meta and a read-only Google Ads server. You can switch off the CloudCart key at any time under Settings → PAT Tokens.

Sources

  1. google-analytics-mcp on GitHubgithub.com
  2. ePrivacy Directive on EUR-Lexeur-lex.europa.eu
  3. google-ads-mcp on GitHubgithub.com
  4. Google Ads API, access levelsdevelopers.google.com
  5. Meta for Developers announcementdevelopers.facebook.com
  6. Ads MCP Server: Get starteddevelopers.facebook.com
The CloudCart teamChecked against the platform documentation. Questions: support@cloudcart.com

Build your online store

The first 3 months on every plan are €1/month. Questions: support@cloudcart.com

Create a store for €1