Implementing Google Analytics 4 (GA4) with FastSpring: Classic Documentation Only

❗️

Important!

This article only applies to FastSpring’s Classic Platform.

The current version of Google analytics is GA4. Google Analytics 4 introduces a set of features that change the way data is collected and organized in your Google Analytics account, so you can get a better understanding of how users interact with your online content. This article will assist you with the integration of Google Universal Analytics 4 with FastSpring (Classic Platform only). For more information about the migration from previous versions please refer to the Google documentation.

Configure your domains in Google Analytics

Enable the cross-domain measurement and further define which links on your site do not trigger Outbound Click events when using enhanced measurement.

  1. Open your Google Analytics account. Go to the Admin menu.
  2. Choose the GA4 property that you want to modify. Then select Data Streams.
  3. Choose the data stream to modify.
  4. Under the Google tag section, select Configure tag settings.
  5. Under the Settings section choose Configure your domains.
  6. In the form add a new row with the following data (as the following image):
    • Match type: Contains
    • Domain: fastspring.com

FastSpring Setup

  1. Go to SpringBoard’s Store Home > External Tracking.
  2. Click Add Tracking Method.



FastSpring offers four tracking types:

  • Google Analytics
  • Google Universal
  • Google Adwords
  • Custom Tracking
  1. Select Custom Tracking Method and click Next.
  2. Enter in a Name that will be used for management purposes only, we recommend “GA4”.
  3. Determine if you want the tracking code to Apply to All Pages (recommended) by selecting the checkbox or only apply to the final order completion page by leaving it unchecked.
  1. Add the following code as it appears below, to the (before) section, and remember to replace it with your MEASUREMENT_ID or you can set up your id using custom parameters. If you need to send more information you can review the Full #{order} Documentation.
<script src="https://www.googletagmanager.com/gtag/js?id=MEASUREMENT_ID"> </script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'MEASUREMENT_ID', {'cookie_flags':'SameSite=None;Secure'});

<if test="#{complete}">

var items = [];
<repeat value="#{order.allItems}" var="orderItem">
items.push({
  'item_name': '#{orderItem.productDisplay}',
  'item_id': '#{orderItem.productName}',
  'price': '#{orderItem.priceTotal.textValue}',
  'quantity': '#{orderItem.quantity}',
  'affiliation': '#{order.siteName}'
});
</repeat>

gtag("event", "purchase", {
        'transaction_id': "#{order.id}",
        'value': '#{order.subTotal.textValue}',
        'currency': '#{order.currency}',
        'items': items
});
</if>
</script>

  1. Click Next.
  2. Move the tracking method to Active Status
  3. Deactivate your old Google Analytics and other external tracking methods.