Connecting Salesforce to GA4
Salesforce holds the opportunity, the amount and the close — the only place the actual revenue outcome is recorded. GA4 is where the business goes to understand what happened, which makes an unattributed conversion there expensive in decisions rather than in ad spend. The join between them succeeds or fails on one thing: whether the GA4 client_id reaches the Salesforce Lead or Opportunity before the conversion happens, because GA4 can only match a conversion it can tie back to a click it recognizes.
Free30 minutesNo obligation
Specific to this pair
Salesforce in GA4: the client_id has to survive lead conversion
Capture GA4's client_id and session_id into custom Lead fields mapped through conversion to Contact and Opportunity. Send generate_lead on Lead creation and purchase at Closed Won through Measurement Protocol, with the Opportunity Id as transaction_id, Amount and currency. Send a refund when a deal leaves Closed Won, and never send rep-created or imported leads without a client_id.
The GA4 client_id has to be captured from the _ga cookie when the web form posts and written to a custom field on the Salesforce Lead, with matching fields on Contact and Opportunity and the lead field mapping configured, or it is thrown away when sales converts the lead. Capture session_id the same way; without it a Measurement Protocol event cannot rejoin the session that produced the form.
Send generate_lead when the Lead is created, then purchase when the Opportunity moves into Closed Won, from a Flow or Apex callout or a scheduled job. Use the Opportunity Id as transaction_id, Amount as value and the opportunity currency. Measurement Protocol only accepts timestamps a few days back, so the deal lands on its close date rather than the form date, and you read it in GA4 by first user source. That is what makes a nine-month enterprise deal visible against the campaign that opened it.
GA4 offers no retraction other than a refund event. When an Opportunity is moved back out of Closed Won, which enterprise pipelines do, send a refund carrying the same transaction_id and amount. Leads created by sales reps, list imports and events have no client_id; they must not be sent through Measurement Protocol, or GA4 fills (direct)/(none) with your outbound pipeline.
Salesforce → GA4 · what breaks
Why this join usually fails — Salesforce → GA4
- 01
The GA4 client_id never reaches Salesforce
Lead conversion is where identifiers die. A custom field on Lead that has no mapped counterpart on Contact or Opportunity is silently discarded when the Lead converts, and nobody notices until months of data are unattributable.
- 02
The identifier is lost at lead conversion
This one failure explains most broken Salesforce attribution. The data is captured correctly, then thrown away by a mapping nobody configured.
- 03
Everything lands under (direct)/(none)
The classic Measurement Protocol symptom, and it always means the same thing: the client_id was missing or wrong, so GA4 had no session to attach the event to and invented a new user.
- 04
Nothing reconciles afterwards
GA4 DebugView shows events arriving with their parameters, and Realtime confirms the user and session they attached to. Neither tells you whether you are double-counting — for that, compare GA4's conversion count against the source system's record for the same window.
Salesforce → GA4 · the fix
What working looks like — Salesforce → GA4
The GA4 client_id on every opportunity
Conversions arriving in GA4
Conversions appear in GA4 attributed to the original session's source and medium, so acquisition reporting reflects what actually drove revenue.
Reconciled against the source
Salesforce → GA4 · architecture
How Salesforce and GA4 actually connect
- 1
Salesforce holds the truth
The opportunity carries the amount, stage and close date. Because Leads convert into Contacts, Accounts and Opportunities, the identifier must be mapped through the conversion or it is dropped exactly at the moment the record becomes valuable.
- 2
GA4 needs a click to match
GA4 needs the client_id to attach a server event to the user and session that produced the click. Without it there is no attribution to inherit and the event is orphaned.
- 3
The identifier is the bridge
The GA4 client_id, captured at the visit and carried into the Salesforce Lead or Opportunity.
- 4
The event source decides reliability
Fire on the transition into Closed Won, carrying the amount and the identifier. Note that Salesforce's own advertising integrations vary in what they support — build on the record, not on a connector that might change.
- 5
Deduplication at the destination
GA4 has no built-in deduplication for Measurement Protocol. If the browser also sends the event, it counts twice. The only reliable approach is to decide per event which side sends it, and enforce that decision — GA4 will not protect you from your own duplicates.
Salesforce → GA4 · normal or broken
Working vs. broken, side by side — Salesforce → GA4
Normal, not a fault
The GA4 client_id present on the opportunity
Sent from a Salesforce flow, Apex trigger or scheduled export on StageName change
Deduplicated correctly
GA4 has no built-in deduplication for Measurement Protocol. If the browser also sends the event, it counts twice. The only reliable approach is to decide per event which side sends it, and enforce that decision — GA4 will not protect you from your own duplicates.
Reconciles with the source
Actually broken
The GA4 client_id missing on most records
Lead conversion is where identifiers die. A custom field on Lead that has no mapped counterpart on Contact or Opportunity is silently discarded when the Lead converts, and nobody notices until months of data are unattributable.
Sent from the browser
This one failure explains most broken Salesforce attribution. The data is captured correctly, then thrown away by a mapping nobody configured.
Counted twice, or not at all
The classic Measurement Protocol symptom, and it always means the same thing: the client_id was missing or wrong, so GA4 had no session to attach the event to and invented a new user.
Nobody has reconciled it
Salesforce → GA4 · diagnose
Diagnostic order — Salesforce → GA4
- 01
Count opportunitys carrying the GA4 client_id
- 02
Follow one real conversion end to end
- 03
Convert a test Lead and inspect the resulting Opportunity
If the identifier is not on the Opportunity, the field mapping is missing. This takes five minutes and rules out the most likely cause outright.
- 04
Check whether server events carry a session and a source
In GA4 Realtime or DebugView, find the event and look at its session and traffic source. A brand-new user with no source on every server event is the missing-client_id signature.
- 05
Read the match rate, not the success message
GA4 DebugView shows events arriving with their parameters, and Realtime confirms the user and session they attached to. Neither tells you whether you are double-counting — for that, compare GA4's conversion count against the source system's record for the same window.
Salesforce → GA4 · prove
How it gets proven — Salesforce → GA4
Source of truth
A Salesforce report of Closed Won opportunities for the same window, by close date.
- The GA4 client_id confirmed present on a live opportunity.
- Server events confirmed in DebugView attaching to an existing session with the original traffic source intact.
- A test lead converted end to end with the identifier confirmed present on the resulting opportunity.
Salesforce → GA4 · free audit
What we check in the free audit
- Count opportunitys carrying the GA4 client_id
- Follow one real conversion end to end
- Convert a test Lead and inspect the resulting Opportunity
- Check whether server events carry a session and a source
- Read the match rate, not the success message
Checked against
A Salesforce report of Closed Won opportunities for the same window, by close date.
Free30 minutesNo obligation
Salesforce → GA4 · when not to buy
When you don't need this — Salesforce → GA4
- Measure identifier coverage yourself first — pull your last hundred opportunitys and count how many carry the GA4 client_id.
- If your Salesforce instance is heavily customized and administered by another team, scope their availability before commissioning this — the build is usually blocked on admin access rather than on the tracking work.
- GA4 is reporting, not bidding. If your problem is ad platform optimization, fix the ad platform destination first — GA4 will not change what any campaign does.
Salesforce → GA4 · what we deliver
What gets built — Salesforce → GA4
Identifier capture into Salesforce
Custom field on Lead, matching custom field on Contact and Opportunity, and the field mapping configured so conversion carries it across. Verify by converting a test lead and reading the resulting opportunity.
Event source: a Salesforce flow, Apex trigger or scheduled export on StageName change
Fire on the transition into Closed Won, carrying the amount and the identifier. Note that Salesforce's own advertising integrations vary in what they support — build on the record, not on a connector that might change.
Dispatch to GA4
Measurement Protocol events with the client_id, session_id and the correct measurement ID and API secret, sent server-side.
Reversals where they exist
An opportunity moved back out of Closed Won can be retracted, and enterprise pipelines do this often enough to be worth wiring.
Written guarantee
95%+ tracking accuracy
Measured against A Salesforce report of Closed Won opportunities for the same window, by close date.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
Salesforce → GA4 questions, answered
Store the GA4 client_id on the Lead and map it to the Opportunity, then send a purchase through Measurement Protocol when the stage changes to Closed Won, using the Opportunity Id as transaction_id.
The client_id was missing, usually dropped at lead conversion or never captured for rep-created leads. GA4 then created a new user with no source.
Almost always because the GA4 client_id never reached the Salesforce Lead or Opportunity. Lead conversion is where identifiers die. A custom field on Lead that has no mapped counterpart on Contact or Opportunity is silently discarded when the Lead converts, and nobody notices until months of data are unattributable. Measure coverage before debugging the dispatch.
The client_id, from the _ga cookie. Measurement Protocol events without it are rejected or create a brand-new user with no session and no source, which is how server events end up filed under (direct)/(none) and make paid channels look worse than they are. Send session_id alongside it so the event joins the existing session, and include engagement_time_msec or the event may not appear as expected in reports.
A Salesforce flow, Apex trigger or scheduled export on StageName change. Fire on the transition into Closed Won, carrying the amount and the identifier. Note that Salesforce's own advertising integrations vary in what they support — build on the record, not on a connector that might change.
GA4 DebugView shows events arriving with their parameters, and Realtime confirms the user and session they attached to. Neither tells you whether you are double-counting — for that, compare GA4's conversion count against the source system's record for the same window.
More on Salesforce → GA4
- Salesforce + GoogleGoogle Ads and GA4 tracking for Salesforce
- Stripe → GA4Connecting Stripe to GA4
- PayPal → GA4Connecting PayPal to GA4
RELATED GUIDES
Where Salesforce → GA4 fits in the rest of your tracking
- Less Annoying CRM → GA4Connecting Less Annoying CRM to GA4
- Capsule → GA4Connecting Capsule CRM to GA4
- Nimble → GA4Connecting Nimble to GA4
- Salesforce → PostHogConnecting Salesforce to PostHog
- Salesforce → MixpanelConnecting Salesforce to Mixpanel
- Law firmsConversion tracking for law firms, without sending case details anywhere
- Zoho → GA4Connecting Zoho CRM to GA4
- Insightly → GA4Connecting Insightly to GA4
Free · 30 min
Get Salesforce and GA4 joined properly
Free30 minutesNo obligation
