Connect Stripe Customer Events with Google Analytics Events
-
Apr 13, 2025

When Paytics sends Stripe events to Google Analytics via the Measurement Protocol, those events often appear as coming from an “Unassigned” source, separate from the client-side interactions recorded in Google Analytics 4 (GA4). While this stil adds some some e-commerce data in your GA4 dashboards, it does not link pre-payment actions (e.g., pageviews, ad clicks, etc.) to the Stripe event. This means you lose a complete view of the user's journey.
Why Link Stripe Events to GA4 Events?
By default, server-side events from Stripe are disconnected from the pageviews and other client-side actions to your site. To fully connect the user’s journey—including impressions, clicks, and final payments—you need to connect Google Analytics’ session and client identifiers with the corresponding Stripe Customer. This will enable you to:
- See Complete Conversion Paths: Track how users move through your site before making a payment and what drives them to purchase.
- Improve Funnel Analysis: Pinpoint where users drop off or complete a conversion, integrating site behavior and Stripe data.
- Enhance Retention Strategies: use combined client-side and Stripe data to segment your audiences, optimize remarketing, and measure lifetime value (LTV).
The Session Script
The Paytics bridges this gap by associating server-side Stripe events with client-side GA4 events through a session script. This script should be added to the <head> tag of every page. Here's how to get the script for your connection:
- Log in to your Stripe Dashboard and open the Paytics app.
- Go to the Settings section of the app.
- Scroll down to the Google Analytics User Mapping section.
- Copy the provided script.
This script allows Paytics to map Google Analytics Client and Session IDs to appropriate Stripe Customer events.
EXAMPLE:
<script> window.paytics = window.paytics || []; window.paytics.push({'stripe_customer_id' : 'STRIPE_CUSTOMER_ID'}); // Replace STRIPE_CUSTOMER_ID with actual Stripe Customer ID when available // Specify user_id ONLY if using GA4’s user_id property with your internal user ID. // Otherwise, delete or ignore the next line. window.paytics.push({'user_id' : 'USER_ID'}); // Replace USER_ID with actual User ID when available. </script> <script async src="https://paytics.io/session.js?id=CONNECTION_ID"></script>
Key Points for This Script
- placement: Add the script to the <head> section of every page.
- stripe_customer_id: Replace STRIPE_CUSTOMER_ID with the actual Stripe Customer ID (when available). This links the on-page user actions to the corresponding server-side Stripe events.
- user_id (optional): If you use GA4’s user id feature, you can push an internal user ID for cross-device tracking. Otherwise, omit that line.
Additional Benefits
Once your Stripe events are connected to GA4 sessions, you can:
- Build Detailed Funnels: Track multiple touchpoints like ad clicks, referrals, and final transactions in Stripe.
- Measure Cart Abandonment More Accurately: Identify users who start checkout but don't complete payment, allowing for better retargeting.
- Analyze Lifetime Value (LTV): Combine subscription or repeat purchase data from Stripe with GA4 segments to enhance your upsell or cross-sell campaigns.
Note: By default, Google Analytics treats Stripe events from the Measurement Protocol as coming from an unknown source. The script above ensures that server-side events ae unified with client-side data, giving you a full view of user activity.