GA4 Setup

Integrate Google Analytics 4 (GA4) with your FastSpring popup, embedded, or web checkout to track purchases and conversion events.

💡

If you use Google Tag Manager to manage GA4, do not set up a separate GA4 integration. Follow the Google Tag Manager guide instead.

Prerequisites

Before setting up the integration, complete the following:

  1. Create a Google Analytics account and copy your Measurement ID.
  2. Add the GA4 snippet to your website following Google's setup documentation.
  3. If you use a popup or embedded checkout, review cross-domain tracking before proceeding.

Set up the integration

Configure for all checkouts

Use this method if you want to apply the same GA4 property across all of your FastSpring checkouts.

  1. In the FastSpring app, navigate to Integrations > Extensions > Google Analytics.
  2. Click Setup.
  3. Enter your Google Analytics Measurement ID and click Enable.

Configure for individual checkouts (optional)

Only follow this step if you need different Measurement IDs for different checkouts. Otherwise, the setup above applies to all checkouts automatically.

  1. In the FastSpring app, navigate to the checkout you want to configure and click Settings.
  2. In the left menu, click Analytics Integration.
  3. Under Google Analytics Integration Behavior, select Use custom Google Analytics property ID for this checkout.
  4. Enter your Measurement ID in the Custom Google Analytics property ID field and click Save.

Cross-domain tracking

Cross-domain tracking ensures that customer sessions are correctly attributed across your site and the FastSpring checkout. Configuration varies by checkout type.

Web checkouts

Enable cross-domain measurement in Google Analytics to prevent Outbound Click events from breaking the session when a customer navigates to the FastSpring checkout.

  1. In your Google Analytics account, go to Admin > Data Streams.
  2. Select the data stream you want to modify.
  3. Under the Google tag section, click Configure tag settings.
  4. Under Settings, select Configure your domains.
  5. Add a new row with the following values:
    • Match type: Contains
    • Domain: onfastspring.com
  6. Repeat to also add paypal.com.

GA4 cross-domain configuration

Popup and embedded checkouts

When using the Store Builder Library (SBL) for popup or embedded checkouts, include the data-decorate-callback attribute in your FastSpring script tag to pass GA4 session data through the checkout.

1. Add the attribute to your FastSpring script:

<script
  id="fsc-api"
  src="https://d1f8f9xcsvx3ha.cloudfront.net/sbl/0.9.2/fastspring-builder.min.js"
  type="text/javascript"
  data-storefront="yourexamplestore.onfastspring.com/popup-yourexamplestore"
  data-decorate-callback="decorateURL">
</script>

2. Add the following function to your page, replacing <MEASUREMENT_ID> with your own:

function decorateURL(url) {
  window.clsid = {
    client_id: '',
    session_id: ''
  };
  gtag('get', '<MEASUREMENT_ID>', 'client_id', function(r) {
    window.clsid.client_id = r;
  });
  gtag('get', '<MEASUREMENT_ID>', 'session_id', function(r) {
    window.clsid.session_id = r;
  });
  var _pl = '&clientId=' + window.clsid.client_id + '&sessionId=' + window.clsid.session_id;
  return url + '?' + _pl;
}

Troubleshooting

If you're seeing data discrepancies or missing events, use the following resources:

💡

Ad-blocking tools can prevent up to 10–15% of transactions from being reported. Absolute metrics like visitors and pageviews are affected, but relative metrics like conversion rates remain accurate. For server-side tracking that bypasses ad blockers, see Google Measurement Protocol.


Did this page help you?