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
- 1Connect your GA4 property to Agentis via Google OAuth (Analytics read-only scope)
- 2Agentis maps GA4 transaction IDs to Shopify order IDs for per-order attribution
- 3Configure attribution model preference (last-click, first-click, or data-driven)
- 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
Solution
Multi-Channel Margin Management
Compare true per-order profitability across your Shopify, Shopify Plus, and SHOPLINE storefronts and B2B orders, with channel-specific fee models and live ERP cost data.
Solution
DTC Brand Margin Protection
Stacked promos, influencer codes, and free-shipping thresholds can push an order below breakeven. Agentis checks every DTC order's true margin within 60 seconds and flags or holds below-floor orders before they ship.
Key Concepts
Margin Analysis
Margin Intelligence
Real-time visibility into per-order, per-SKU, and per-channel profitability using live data from ERP, logistics, and FX systems.
Margin Analysis
Contribution Margin
The revenue remaining after deducting all variable costs associated with fulfilling an order, including COGS, shipping, payment processing fees, and pick-and-pack labor.
Margin Analysis
Margin Leakage
The gradual, often undetected loss of profit across many orders, driven by small per-order cost overruns that compound into significant revenue erosion over time. Also called revenue leakage, a term more common in marketplace-seller (Amazon/Walmart) contexts for the same underlying pattern.
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.