PayPal is still one of the most trusted ways to pay online, especially for international buyers. For tracking, it causes two problems I see in almost every audit: PayPal sales that never appear in GA4 or the ad platforms, and sales that appear but are credited to paypal.com instead of the ad that brought the buyer. Both are fixable. This guide shows how, for each type of PayPal integration.
If you want this set up for you, see my PayPal checkout tracking page.
How do PayPal payments work, and why does it matter for tracking?
How you track PayPal depends on how PayPal is installed, because each integration sends the buyer on a different path.
| PayPal integration | What the buyer sees | Where to track the purchase |
|---|---|---|
| Smart Buttons (JavaScript SDK) | A PayPal pop-up over your page | On your page, after the server captures the order |
| Redirect buttons (older PayPal buttons) | A redirect to paypal.com and back | On the thank-you page, with Auto Return on |
| A store plugin (WooCommerce, Shopify) | PayPal as one payment method | From the store order, like any other purchase |
| Any of the above + webhooks | Nothing extra | On the server, from PayPal's webhook |
The most important rule is the same everywhere: a purchase is a captured payment, not an approved order.
What is the difference between approved and captured?
When a buyer clicks "Pay" in PayPal, the order is approved: the buyer agreed to pay. The money moves when your site captures the order. In between, a capture can still fail, for example if a funding source is declined.
If you fire purchase on approval, you will count payments that never completed. Fire it after a successful capture, with the capture ID as the transaction ID.
How do you track PayPal Smart Buttons?
Smart Buttons are the easiest to track, because PayPal opens in a pop-up and the buyer never leaves your site.
- In your PayPal button code, the
onApprovefunction calls your server to capture the order. - When the capture response comes back successful, read the capture ID, amount and currency from it.
- Push a
purchaseevent to the data layer with those values. - Google Tag Manager sends it to GA4, Google Ads and Meta.
dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: '3C679366HH908993F', // PayPal capture ID
value: 49.0,
currency: 'USD'
}
})
Only push this after the capture succeeds, not at the start of onApprove.
How do you track redirect PayPal buttons?
Older PayPal buttons send the buyer to paypal.com. Whether they come back depends on your PayPal settings.
- In your PayPal account's website payment preferences, turn on Auto Return and set a Return URL to your thank-you page.
- On the thank-you page, fire
purchaseonly when PayPal's transaction details are present, and use the transaction ID so refreshes are deduplicated. - Test a real payment and check that the browser actually lands on your thank-you page; button code can include its own return settings that change the behaviour.
Even with Auto Return, some buyers close the window before the redirect. That is why the next method matters.
How do PayPal webhooks fix missing purchases?
Webhooks let PayPal tell your server about a payment, whether or not the buyer comes back.
The webhook events that matter:
PAYMENT.CAPTURE.COMPLETED— the payment was captured. This is your purchase.PAYMENT.CAPTURE.DENIEDorPAYMENT.CAPTURE.PENDING— not yet a purchase.PAYMENT.CAPTURE.REFUNDED— optional, for refunds in GA4.CHECKOUT.ORDER.APPROVED— useful to capture orders whose buyers closed the window, but not a purchase on its own.
Point the webhook at a server-side GTM container (or a small endpoint that forwards to it), turn PAYMENT.CAPTURE.COMPLETED into a purchase, and send it to GA4, Google Ads and Meta with the same transaction ID your browser event uses. Check a real webhook payload to see which of your own IDs (for example custom_id or invoice_id, if you set them when creating the order) are included, so you can match it to your order. For the server side, see server-side tracking explained.
PayPal's older IPN and PDT notifications still exist for legacy integrations, but PayPal recommends its newer APIs for new builds.
Why does GA4 credit sales to paypal.com?
When a buyer returns from PayPal to your thank-you page, GA4 can see paypal.com as a referrer and start a new session with PayPal as the source. Your purchase is then credited to PayPal, not to Google Ads or Meta.
The fix is to add paypal.com under List unwanted referrals in your GA4 tag settings. I explain the exact screen in GA4 cross-domain tracking, and the wider attribution problem in why paid traffic shows as Direct or Unassigned.
How do you connect server purchases to the ad click?
A webhook knows the payment, not the ad. Save the GA4 client ID, gclid and Meta _fbc/_fbp before the buyer opens PayPal, and attach a reference to the PayPal order so the server can look them up. The full method is in keeping click IDs through a third-party checkout.
How do you test PayPal tracking?
- Use a PayPal sandbox account for a full test payment
- Confirm
purchasefires only after capture, with the capture ID - For redirect buttons, confirm the buyer lands on the thank-you page
- Check the webhook delivery in the PayPal developer dashboard
- Confirm one purchase in GA4 DebugView, Google Ads diagnostics and Meta Test events
- After a week, compare tracked purchases with your PayPal activity
Final thoughts
PayPal tracking comes down to three habits: count captures, not approvals; give buyers a way back to your site; and let webhooks confirm what the browser misses. Add paypal.com to your unwanted referrals and your ads finally get credit for PayPal sales. If you want it done for you, see my PayPal checkout tracking service.