Analytics

Attribute Traffic Source Costs to Per-Order Margin for True Channel Profitability

Agentis integrates with GA4 to overlay traffic acquisition costs onto per-order margin data, revealing which channels, campaigns, and sources drive profitable orders vs. revenue-positive but margin-negative traffic.

How It Works

Agentis reads GA4 session and attribution data via the Data API to connect traffic sources to individual orders. When combined with ad spend data from Google Ads, Meta, and other platforms, Agentis calculates the customer acquisition cost per order and includes it in the all-in margin calculation. A $50 order from a paid Instagram ad with a 15% discount and $12 CPA has a very different margin than the same order from organic search.

Data Flows

  • →Session source/medium and campaign data from GA4 → Agentis traffic attribution model
  • →Transaction and revenue data from GA4 ecommerce events → Agentis order-channel mapping
  • →User acquisition path from GA4 → Agentis first-touch and last-touch attribution
  • →Ad spend data (imported into GA4) → Agentis customer acquisition cost per order

Benefits

  • Know which traffic sources drive profitable orders, not just revenue
  • Calculate true margin by channel: organic search vs paid social vs email have vastly different costs
  • Identify campaigns where CPA + discount + COGS leaves zero margin despite strong ROAS
  • Make budget allocation decisions based on margin contribution, not just attributed revenue

Setup

  1. 1Connect your GA4 property to Agentis via Google OAuth (Analytics read-only scope)
  2. 2Agentis maps GA4 transaction IDs to Shopify order IDs for per-order attribution
  3. 3Configure attribution model preference (last-click, first-click, or data-driven)
  4. 4Import ad spend data from Google Ads and Meta for complete CPA calculations

Technical Details

Agentis uses the GA4 Data API (v1beta) with Google OAuth2 authentication (analytics.readonly scope). We query the runReport endpoint to extract session source, medium, campaign, and transaction data. Order matching uses the transaction_id parameter from GA4's ecommerce events, cross-referenced with Shopify order IDs. Ad spend data is pulled from the Google Ads API and Meta Marketing API where connected. Data syncs daily (GA4 processing latency is 24-48 hours). Attribution modeling supports last-click, first-click, and GA4's data-driven attribution.

Frequently Asked Questions

Can GA4 data be used in per-order margin checks?

Not directly, as GA4 data has 24-48 hour processing latency. However, Agentis uses historical channel-level margin data to apply estimated acquisition costs when it checks each order. For example, if paid social orders average $8 CPA, Agentis applies that estimate to the margin calculation for orders identified as paid social.

Does Agentis replace Google Analytics?

No. Agentis complements GA4 by adding margin data that GA4 doesn't have. You continue using GA4 for traffic, behavior, and conversion analytics. Agentis adds the profitability layer.

Which attribution model does Agentis use?

You choose. Agentis supports last-click, first-click, and GA4's data-driven attribution model. Last-click is a simple starting point; data-driven attribution becomes useful once you have sufficient volume.

Related Solutions

Key Concepts

Free Audit, No Commitment

Protect Every Order's Profit Margin

See exactly how much margin Agentis can recover for your store in 7 days, no commitment required.