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.
- Open your Google Analytics account. Go to the Admin menu.
- Choose the GA4 property that you want to modify. Then select Data Streams.
- Choose the data stream to modify.
- Under the Google tag section, select Configure tag settings.
- Under the Settings section choose Configure your domains.
- In the form add a new row with the following data (as the following image):
- Match type: Contains
- Domain: fastspring.com
FastSpring Setup
- Go to SpringBoard’s Store Home > External Tracking.
- Click Add Tracking Method.
FastSpring offers four tracking types:
- Google Analytics
- Google Universal
- Google Adwords
- Custom Tracking
- Select Custom Tracking Method and click Next.
- Enter in a Name that will be used for management purposes only, we recommend “GA4”.
- 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.
- 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>
- Click Next.
- Move the tracking method to Active Status
- Deactivate your old Google Analytics and other external tracking methods.
Updated 6 months ago