Setting up & Configuring Google Analytics in SuiteCommerce

in , , November 1st, 2024
a computer screen with a bunch of data on it

Google Analytics is a third-party analytics solution that helps you evaluate traffic on and to your website through visitor tracking data. This information can then be used to optimize your site content and/or for ad campaigns.

Methods for Setting Up Google Analytics for SuiteCommerce

There are two methods for setting up Google Analytics in SuiteCommerce, which are detailed below. Both require setting up a Google Analytics account and GA4 property first.

The first method (aka the simple method) will allow Google Analytics to capture standard website visitor information such as where they came from, geographic location, browser, device type, and number of site/page visitors.

The second method (or customizable/advanced method) will do the same as method 1 PLUS allows you to add Google Analytics code snippets that would allow for tracking of clicks (i.e., registration, add to cart, in-site links, etc.), submit (i.e., going from cart to check out, form submission), and order tracking.

Prerequisite: Set up a Google Analytics account and GA4 property. Google has well outlined/documented this in this article.

Method 1 - Simple Google Analytics Setup

  • Create/set up a Google Analytics account & GA4 property if you have not already done so.
  • Log in to NetSuite.
  • Go to Commerce > Websites > Configuration.
  • Select the website & domain you wish to add Google Analytics to.
  • Click Configure.
  • Go to the Integrations tab, then the Google Analytics 4 sub-tab (see image).
  • Enter your Google Analytics ID 7 domain as shown/set up in your Google Analytics account.
  • Click Save.

Method 2 - Customizable /Advanced Google Analytics Setup

Step 1: Create/set up a Google Analytics account & GA4 property if you have not already done so

  • Once your Google Analytics account is created, add a profile in the account for the domain you want to track (typically the main URL of your website)
  • On the Standard tab in the Analytics account profile, select multiple top-level domains
  • Copy the tracking pixel code provided by Google Analytics
  • Click Save and Finish
  • Next to Main Website Profile Information on the list of Website Profiles, click on Edit
  • Select Yes as the E-Commerce Website radio option
  • Click Save Changes

Step 2. Log in to NetSuite

Step 3. Go to Commerce > Websites > Website List

  • Click Edit next to the website name
  • Click the Analytics subtab
  • In the Addition to <head> field, paste the tracking code from above.
  • Your tracking code will now be added to every page of your SuiteCommerce site.

Step 4. Other tracking snippets can be added in this same subtab

  • Analytics Click Attributes - code in this field modifies link URLs by adding your tracking pixel. The analytics click attributes snippet will track things like registration, checkout, add to cart, & other links to the checkout page(s).
onclick="if(typeof(_gaq._getAsyncTracker) == 'undefined') { return true; } else { _gaq.push(['_link', this.href]); return false; }"
  • Analytics Submit Attributes - code in this field captures data when shoppers checkout from the shopping cart & when they submit forms on your website.
onsubmit="_gaq.push(['_linkByPost', this]); return true;"
  • Order Tracking Script HTML - The code in this field is applied to the order confirmation "Thank You" page, which displays after a shopper submits a web order. You can use the code below to get started.
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '<account number>']);
  _gaq.push(['_setDomainName', 'none']);
  _gaq.push(['_setAllowLinker', true]);
 _gaq.push(['_addTrans',
   "<%=getCurrentAttribute('confirmation','ordernumber')%>",
   "<%=getCurrentAttribute('site','name')%>",
   "<%=getCurrentAttribute('confirmation','subtotal')%>",
   "<%=getCurrentAttribute('confirmation','tax')%>",
   "<%=getCurrentAttribute('confirmation','shipping')%>",
   "<%=getCurrentAttribute('confirmation','shiptocity')%>",
   "<%=getCurrentAttribute('confirmation','shiptostate')%>",
   "<%=getCurrentAttribute('confirmation','shiptocountry')%>"]);
 var itemsInOrder = "<%=getCurrentAttribute('confirmation','orderitems')%>";
 var lineItem = itemsInOrder.split("||");
 for(var inum = 0; inum < lineItem.length; inum++)
 {
 var itemAttributes = lineItem[inum].split("|");
 _gaq.push(['_addItem',
         "<%=getCurrentAttribute('confirmation','ordernumber')%>",
         itemAttributes[0],
         itemAttributes[1],
         itemAttributes[2],
         itemAttributes[3],
         itemAttributes[4]]);
   }
   _gaq.push(['_trackTrans']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
Important: replace <account number> in the code above with your Google Analytics account number.

Step 5. Check the Enable Google Analytics Integration box

This passes Google tracking cookies from shopping to checkout. This, plus fields added in the click attributes, submit attributes, and order tracking HTML, are required for cross-domain analytics tracking. Clear this box if Google Analytics interferes with a custom solution that you have already implemented for cross-domain data tracking.

Step 6. Click Save

Verify that Website Analytics Data is Being Captured

Place a test order to verify the data is being captured on the order confirmation page. Then, on the confirmation page, from the view menu in your browser, select View Source. You should see values for each tag in the script that you added to the Order Script Tracking HTML field.

Notes on Other Google Analytics Functionality

  • Track E-Commerce Activity: For tracking ecommerce activity, ecommerce events must be set up in your analytics account. Follow the information in this Google article for that.
  • Track Site Searches: To track searches on your site and understand user behavior better, follow the information in this Google article.

Author: Daniel Dobson


Got stuck on a step in this article?

We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!

FREE SuiteCommerce Book

If you liked this article, you'll LOVE our book on SuiteCommerce! Order the free SuiteCommerce book today, and we'll even pay for shipping!

Oracle NetSuite Alliance Partner & Commerce Partner

If you have general questions about SuiteCommerce or more specific questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!

We are a premium SuiteCommerce agency that creates powerful customer portals. Unlike our competitors, we have already solved your problems.

 
 

Want to keep learning?

Our team of NetSuite professionals has written articles on a wide variety of NetSuite topics, from SuiteCommerce tips, to recommended NetSuite solutions, to available support services, and more! 

Your cart