Browse by Topic

Setting Up Google Analytics

Google Analytics is a free analytics tool that helps you track visitors and conversions on your store. It allows you to gain further insight into your visitors, such as which pages they are visiting the most, what channels are driving the most traffic to your store, and which products are performing best.  With Google Analytics Real-Time reports, you can even see how many visitors are viewing your store at any given moment.  Real-Time reports allow you to see if a current promotion is driving more traffic to your store, the effects on store traffic from social media posts, traffic driven by content changes and more, making Google Analytics virtually essential.  To set up Google Analytics, you will need to create and verify your Google account.

Our Google Analytics integration supports Enhanced Ecommerce and Site Search.

Anyone using a Stencil or Blueprint theme can take advantage of our updated integration, but only those using Cornerstone or a theme that supports Data Tags will get full functionality. See Requirements & Limitations to learn more.


Manual Setup

These steps will show you how to set up Google Analytics for Ecommerce Tracking and how to implement the code into your store manually. There are a few notes to be aware before continuing.

  • This implementation does not support Enhanced Ecommerce.
  • This implementation method can be used with either the Google's analytics.js or the Global Site Tag (gtag.js).
  • You must have a dedicated SSL as this feature does not work with the shared SSL certificate.
  • If using the manual setup, Enable DataTags should not be enabled. (This setting is visible only for stores on a Blueprint theme.)

Setting up Google Analytics

Ecommerce Tracking

1. In your Google Analytics account, go to AdminViewEcommerce Settings.

Ecommerce Settings highlighed in the View list

2. Under Enable Ecommerce, toggle the status to ON and leave Enhanced Ecommerce Settings set to OFF. Save your changes.

Enable Ecommerce set to the ON state and the Save button highlighted

3. Copy the following tracking code.

<script async src=""></script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxxxxx-x');

function trackEcommerce() {
    function gaAddTrans(orderID, store, total, tax, shipping, city, state, country, currency, channelInfo) {
        var transaction = {
            id: orderID,
            affiliation: store,
            revenue: total,
            tax: tax,
            shipping: shipping,
            city: city,
            state: state,
            country: country

        if (currency) {
            transaction.currency = currency;

        ga('ecommerce:addTransaction', transaction);
    function gaAddItems(orderID, sku, product, variation, price, qty) {
        ga('ecommerce:addItem', {
            id: orderID,
            sku: sku,
            name: product,
            category: variation,
            price: price,
            quantity: qty

    function gaTrackTrans() {

    function gtagAddTrans(orderID, store, total, tax, shipping, city, state, country, currency, channelInfo) {
        this.transaction = {
            transaction_id: orderID,
            affiliation: store,
            value: total,
            tax: tax,
            shipping: shipping,
            items: []

        if (currency) {
            this.transaction.currency = currency;

    function gtagAddItem(orderID, sku, product, variation, price, qty) {
            id: sku,
            name: product,
            category: variation,
            price: price,
            quantity: qty

    function gtagTrackTrans() {
        gtag('event', 'purchase', this.transaction);        
        this.transaction = null;

    if (typeof gtag === 'function') {
        this._addTrans = gtagAddTrans;
        this._addItem = gtagAddItem;
        this._trackTrans = gtagTrackTrans;
    } else if (typeof ga === 'function') {
        this._addTrans = gaAddTrans;
        this._addItem = gaAddItems;
        this._trackTrans = gaTrackTrans;

var pageTracker = new trackEcommerce();


Installing the Tracking Code

Now we need to add the tracking code to your BigCommerce store.

1. In the BigCommerce control panel, go to Advanced SettingsWeb Analytics.

2. Check the box next to Google Analytics, then Save.

Google Analytics checkbox

3. Click the Google Analytics tab that appears at the top of the page.

Google Analytics tab

4. Paste the tracking code into the text box and replace UA-xxxxxxxx-x with your Google Tracking ID.

Example installation using the manual method

5. Save your changes.


Excluding Referrals From Payment Gateways

To avoid transactions made through payment gateways such as PayPal Express Checkout appearing as referrals in Google Analytics, you will need to add the payment gateways to your Referral Exclusion List.

1. In your Google Analytics account, go to AdminPropertyTracking InfoReferral Exclusion List.

Tracking Info and Referral Exclusion List

2. Click Add Referral Exclusion.

Add Referral Exclusion

3. Enter the domain of your payment gateway (such as in the Domain field, then click Create to save your changes.

Domain field and Create button in the Referral Exlusion dashboard



Can I send custom dimensions and metrics to Google Analytics?

Yes. Both our manual and recommended methods can send custom dimensions and metrics. Note that if you're using the manual method, you'll need to add code similar to the one below with the information you would like to send.

ga('send', 'pageview', {
  'dimension17':  channelInfo.type,

See Google Analytics' developer documentation  and support documentation on custom dimensions and metrics for more information.

Was this article helpful?