Collapse Menu
Classic Docs
Order Page Config, Design and Page Flow
Advanced Features
Subscriptions and Saasy
Contact Support

Integrating Google Universal Analytics with FastSpring

Google Universal Analytics 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. Custom dimensions and custom metrics are like default dimensions and metrics, except you create them yourself. Use them to collect data that Classic Google Analytics does not automatically track.  This article will assist you with the integration of Google Universal Analytics  with FastSpring.

Initial Setup

Google Universal Analytics Setup

If you are already using Classic Google Analytics, follow the two step Universal Analytics Upgrade process to upgrade. 

If you are not already using Classic Google Analytics, sign up for a Google Analytics Account. Upon signing up, Google Analytics will provide you with a tracking code which you will paste onto your web pages and which will be used to integrate with FastSpring. An example of the format of the tracking code is UA-XXXXXXXX-X.

In Google Analytics, click on Admin. Select your Account and Property. Under View, click View Settings.

3.png 4.png

FastSpring recommends two specific general settings: (1) in the Exclude URL Query Parameters field, exclude jsessionid, csid, and (2) for Currency displayed as, select US Dollar (USD $). Click Save.

5.png

In the left column, click Ecommerce Settings. FastSpring recommends one specific Ecommerce setting: Enable Ecommerce's Status should be ON. Note: Enhanced Ecommerce enables product impression, promotion, and sales data to be sent with any of your Google Analytics pageviews and events. If you would like this information, turn it on.

6.png  7.png

FastSpring Setup

Go to SpringBoard's Store Home » External Tracking. Click Add Tracking Method. 

45.png0.png

Select Google Universal Analytics, enter in the Google Analytics Tracking ID under Web Property ID, and click Next. 

GA_ID.png

Under Custom Parameters, type Autolink Domain and your website URL. Adding the Auto Link parameter, along with adding some code (provided below) to your webpages, will link the two domains in Google Universal Analytics.

1.png

Add the following GA code, exactly as it appears below, to the </body> (before) section.  

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

<choose>
<when has="#{param['Autolink Domain']}">
ga('create', '#{param['Web Property ID']}', 'auto', {'allowLinker': true });
ga('require', 'linker'); 
ga('linker:autoLink', ['#{param['Autolink Domain']}', 'fastspring.com']);
</when>

<otherwise>
ga('create', '#{param['Web Property ID']}', 'auto');
</otherwise>
</choose>

ga('send', 'pageview');

<if test="#{complete}">
ga('require', 'ecommerce', 'ecommerce.js');
ga('ecommerce:addTransaction', {
  'id':'#{order.id}',
  'affiliation':'#{order.siteName}',
  'revenue':'#{order.subTotal.textValue}',
  'currency':'#{order.currency}'
});

<repeat value="#{order.allItems}" var="orderItem">

ga('ecommerce:addItem', {
  'id': '#{order.id}',
  'name': '#{orderItem.productDisplay}',
  'sku': '#{orderItem.productName}',
  'price': '#{orderItem.priceTotal.textValue}',
  'quantity': '#{orderItem.quantity}'
});

</repeat>
ga('ecommerce:send');
</if>
</script>

 

Move the tracking method to Active Status. Finally, remember to deactivate your Google Analytics and other external tracking methods that you now have set up to be served via Google Universal Analytics.

544.png

Updating your Webpages

Copy the following code and paste it onto every page you want to track immediately before the closing </head> tag. Be sure to replace UA-33288836-1 with your tracking code and replace yourwebsite.com with your website URL.

<script type="text/javascript">

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); 

ga('create', 'UA-33288836-1', 'yourwebsite.com'); 
ga('send', 'pageview'); 

// Load the plugin.
 ga('require', 'linker'); 

// Define which domains to autoLink. 
ga('linker:autoLink', ['fastspring.com']);

</script>

Event Tracking (Optional)

The  _gaq.push(link) that used to be added to links and required in Classic Google Analytics is no longer needed. Instead, on any page with links to your FastSpring store, if you want to track the click event (which will show in Events in your Google Universal Analytics account), you need to add a unique id that identifiies the product.

For example, <a href="http://sites.fastspring.com/teststore/product/product1"> would need to become something like <a href="http://sites.fastspring.com/teststore/product/product1" id="p1"> . To track events, you need to add the following code to the bottom of your webpage before the </body> tag. Be sure to replace p1 with the unique id of your link. 

<script type="text/javascript">

var downloadLink1 = document.getElementById('p1');
addListener(downloadLink1, 'click', function() {
  ga('send', 'event', 'a', 'click', 'addToCart1');
});

function addListener(element, type, callback) {
 if (element.addEventListener) element.addEventListener(type, callback);
 else if (element.attachEvent) element.attachEvent('on' + type, callback);
}
</script>

If you have links to multiple products on one page, add a unique id to the link for each different product, and then repeat the code below for each unique product id, following the example below. Make sure to replace p1, p2, etc. with the unique ids of your product links.

<script type="text/javascript">

var downloadLink1 = document.getElementById('p1');
addListener(downloadLink1, 'click', function() {
ga('send', 'event', 'a', 'click', 'addToCart1');
});

var downloadLink2 = document.getElementById('p2');
addListener(downloadLink2, 'click', function() {
ga('send', 'event', 'a', 'click', 'addToCart2');
});

function addListener(element, type, callback) {
if (element.addEventListener) element.addEventListener(type, callback);
else if (element.attachEvent) element.attachEvent('on' + type, callback);
}

</script>

Google Analytics Views

When you set up tracking, Google Universal Analytics suggests you do certain things with your views. While we have tried to summarize their suggestions below, you may want to read Google Analytic's documentation on key components for up-to-date information.

  • Set up a master view for your primary website domain.

    It is recommended that you set up a master view for your primary website domain that should have no filters added to it. Without filters, your master view will always have baseline historical data for your primary website domain that you can refer to if you make errors when setting up filters in your cross-tracking view. 
     
  • Create a view for cross-domain tracking.

    After you have set up a master view, in the Admin menu, click on your account and select the same Property as you did for your master view. Under View, click Create New Profile. Create a profile especially for cross-domain tracking. 

    12.png
  • Modify your cross-domain view with a filter to show the full domain in your content reports.

    Once you have domain linking established, you will see only the request URL in the content reports, and not the top-level or sub-domain for a given page. For example, for visits to the pages  http://www.example.com/index.php and another page  http://sub.example.com/more.php
    the reports will show index.php and more.php. You will not be able to distinguish which page is from which domain. To show the domain in the page reports, make sure you are in the cross-domain view and set a filter to include all components of the page URL by following these steps:

    1. In the Admin menu, click on your Account, and then click All Filters. Click New Filter.

      8.png  9.png
    2. Enter in a Filter Name. For Filter Type, select Custom Filter. Then Select Advanced.10.png
    3. Set the following Advanced settings:
      • For FieldA » Extract A

        Enter Hostname and set the value to  (.*), which is an expression that captures all characters.
      • For FieldB » Extract B

        Enter Request URI and set the value to  (.*), which is an expression that captures all characters.
      • For Output To » Constructor

        Enter Request URI and provide $A1$B1 as the value for that choice. 
    4. Under Apply Filter to Views, select your Cross-Domain Tracking Profile from Available Views, and click Add. This action will move the profile to Selected Views. Click Save.

      11.png

Your reports will now show www.example.com/index.php and sub.example.com/more.php and this will capture the www.example.com portion of your URL and include that at the beginning of your page URL in the content reports section.

We're Here to Help

For assistance with integrating Google Universal Analytics with FastSpring, please open a support ticket.