You are here: Administration > Settings > Site Settings > Configure E-Commerce tracking for Google Universal Analytics

Configure E-Commerce tracking for Google Universal Analytics

If you use Google Universal Analytics reports to track E-Commerce conversions,you must configure Blackbaud NetCommunity to provide the service with purchase information. You can track and report on revenue transactions made on pages that contain these part types: Donation Form, Membership Form, Event Registration Form, and Payment 2.0. If you have the eStore customization, you can also track transactions on pages with the eStore Storefront part.

First you add code to the script you receive from Google Universal Analytics to monitor whether users complete E-Commerce purchases. Add the code to the script you entered when you enabled tracking in Blackbaud NetCommunity so the program includes the additional tracking requirements on each page of your website. Next, use an Unformatted Text part to add another script to pages that include transaction part types. The additional script is necessary because transactions are processed separately from the website by a secure payment processing service. The script receives transaction information from the processing service during the confirmation step and forwards the purchase details to Google Universal Analytics.

1. Open Blackbaud NetCommunity. On the Administration page, select Sites & settings.
2. Select the site to configure and then select the Settings tab.
3. In the Site Tracking Script box, add this section of code to the Google Universal Analytics script you entered when you enabled site tracking for the website. Add the code below the information in the field before </script>. For information about how to enable site tracking, see Site tracking settings.
     ga('require', 'ecommerce');

The combined script should look similar to the one below. Your version should include the account ID provided by Google Universal Analytics in place of UA-XXXXXXXX-Y. Also, if you are testing your website locally, replace ga('create', 'UA-XXXXXX-Y', 'auto'); with ga('create', 'UA-XXXXXX-Y', {'cookieDomain': 'none'});.

     <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-XXXXXXXX-Y', 'auto');
       ga('send', 'pageview');
       ga('require', 'ecommerce');
     </script>
4. Open Blackbaud NetCommunity. From Parts, create a new Unformatted Text part. For information about how to create an Unformatted Text part, refer to Unformatted Text.
5. In the box, enter the script below and then click Save.
     <script type="text/javascript">
         BLACKBAUD.netcommunity.api.DonationConfirmation.add(function (data) {
             if (data.TransTotal) {
                 ga('ecommerce:addTransaction', {
                     'id': data.TransID,
                     'affiliation': '',
                     'revenue': data.TransTotal,
                     'shipping': '',
                     'tax': ''
                 });
                 for (var i = 0; i < data.Items.length; i++) {
                      ga('ecommerce:addItem', {
                          'id': data.Items[i].ID,
                          'name': data.Items[i].Name,
                          'sku': data.Items[i].SKU,
                          'category': data.Items[i].Name,
                          'price': data.Items[i].Price,
                          'quantity': data.Items[i].Quantity
                       });
                  }
                  ga('ecommerce:send');
                  ga('ecommerce:clear');
            }
       });
     </script>

Warning: This code applies to standard Blackbaud NetCommunity transactions. If your site processes custom transaction data, please contact Blackbaud Professional Services or a developer who is familiar with the Google Universal Analytics API to configure the E-Commerce code. This code is also provided as an example from Google Universal Analytics and may not be the most recent version. To ensure that you have the correct code, refer to Google Universal Analytics.

6. Select Show advanced options.
7. In the Placement in HTML field, select “At the end of the <body> tag.”
8. Place the Unformatted Text part on any page that includes one of these part types: Donation Form, Membership Form, Event Registration Form, and Payment 2.0. The script you entered in the Unformatted Text part sends tracking information to Google Universal Analytics about transactions made on those pages. The tracking information includes:

Data ID in

Google Analytics

Description of data type

data.TransTotal

Total dollar amount for the transaction.

data.TransID

Identifies the transaction.

data.Items

Items included in the transaction. If the transaction contains multiple items (for example, a transaction from a Payment 2.0 part may include several purchased items), the items are identified as data.Item[0], data.Item[1], data.Item[2], etc.

data.Items.ID:

Associates an item with a transaction. This is the same value as the TransID.

data.Items.SKU

Unique SKU used to track the price and quantity of an item.

data.Items.Name

Human readable name for an item.

data.Items.Price

Price of an item.

data.Items.Quantity

Number of items purchased of the same type.