How to easily set up Google Analytics tracking for Ecommerce

April 18, 2018
14 minute read

google analytics ecommerce tracking

Google Analytics is by far the most used analytics tool available. It’s estimated that more than 80% of all websites worldwide use Google Analytics (GA) for measuring their website usage. However, many users jump straight in without laying a strong foundation or gaining a proper understanding of the tool.

Eventually, this headfirst approach can end up costing business owners time, money, and a fair bit of confusion. Of course, Analytics can’t track visits that have already happened, so time spent correcting settings means that data will be lost. Collecting the right data from the on-set will save you a lot of headache later on.

When properly set up, Analytics can give you a better understanding of your business. It tells you who your customers are, how they find your site, and what they do once they get there. Clearly, GA is a critical tool for enhancing e-commerce performance, however, before you start reaping the benefits, first you must have the proper set-up.

Who Needs Analytics?

Google Analytics allows you to measure the results of individual campaigns in real-time, compare data to previous periods, track conversion rates, customer demographics, and traffic data. It provides you with your visitor’s country of origin, and importantly, the source of your traffic. In a nutshell, it tells you how many of your visitors convert to customers, and whether your marketing tactics are really working to generate more business. Basically, it’s doesn’t matter if you’re a small mom and pop, or running a million dollar ecommerce business-- you need properly configured Analytics to succeed.

Step One: Lay a Strong Foundation

Before getting stuck in the nitty-gritty of Google Analytics, first you must go back to the basics and ask yourself two important questions:

  1. What do I want to achieve?

  2. What metrics will help me get there?

Data is great, but if you don’t know where you’re heading or how you’ll get there, it won’t do you much good in the end. Once you’ve tackled these two critical steps, then you can get down to business setting up and configuring Google Analytics with a clear view of what exactly you want it to do.


1. What do you want to achieve?

This is likely something you’re well-acquainted with and have been working towards long before you ever heard the words “Google Analytics for ecommerce.”

Let’s be real – the reason you, as a ecommerce business owner, care about Google Analytics, is not higher traffic, lower bounce rates, user engagement, etc. Ultimately you care that people are completing desired actions on your site, namely, purchases or conversions. As conversions equal sales, revenue, and ultimately a profitable business, this is your bread and butter.

To will give you a good idea of what’s happening in your business, and how well you’re progressing towards your conversion objectives, first you need to select a few stated targets and measurements that are easily trackable. For most e-commerce business owners, these can be grouped into four areas:

google analytics ecommerce tracking

Overarching Goals

On overarching goal for an ecommerce retailer is likely to be financial. For example, Lazy B General Store, an online western wear retailer uses the following overarching business goal:

“To double sales by increasing depth and breadth of product range.”


To achieve their overarching business goal, Lazy B might set the following sub-goal:

“Double sales of Twisted X Boots”

Key Performance Indicators (KPIs)

As your main business objective, overarching goals, and sub-goals revolve around boosting conversions, KPIs should be sales-oriented.

For example, Lazy B uses the following KPIs to track their progress towards business goals:

  • Hourly, daily, weekly, monthly, and annual sales of Twisted X Boots
  • Average order size
  • Shopping cart abandonment rate

Performance Targets

For each KPI Lazy B sets a number of performance targets to measure progress. These could include:

“This month we sold 20 pairs of boots, next month we should aim to sell 25.”


2. Focus on metrics that matter

The next order of business before revving up the Google Analytic engine is to decide what kind of metrics you want to measure. Analytics offers an almost endless stream of metrics, so it’s easy to get off target. A good rule of thumb is to focus on data that is actionable, will help you make a decision, or answer a specific question. For e-commerce retailers, the most important metrics can be organized into 4 areas.

Conversion rate

As we know, this is a pretty big deal for e-commerce businesses. It’s a good overall indicator of success, so it’s important that you keep a close eye on it.

There are a few metrics related to conversion data that you should focus on:

  1. Conversion by traffic source: Where are your converting customers coming from? Use this data to determine where you should be investing in driving traffic
  2. Conversion of new vs. returning visitors: Segment conversions of new visitors vs. returning visitors. Conversions for returning visitors are traditionally higher.
  3. Revenue: How much money are you making?
  4. Profit: What remains after you subtract the cost of running the store?
  5. Return on Investment: How much are you making vs. how much you’re spending?

Conversion by product

This is an especially important metric for ecommerce retailers with a large inventory. Tracking the performance of individual products will help you identify your most popular products, as well as the low performers. It can also help you make adjustments to your pricing strategy, descriptions, images, product page optimizations, etc.

Traffic Sources

Knowing how customers are finding your site is pretty important if you want to keep them coming back. The main traffic sources you’ll see in your GA account include:

  1. Direct: Visitors that arrive directly on your site by either entering your URL into their browser’s address bar; clicking on a bookmark; or following a link sent in email or other social messenger
  2. Organic Search: Also known as search engine traffic. These are the visitors that arrive on your site by clicking links found on a search results page of a search engine
  3. Referral: Visitors that click on a link on another site and land on your site
  4. Social: Visitors that land on your site via links on social media channels (Facebook, Instagram, Twitter, etc.)
  5. Email: Clicks from links in emails you sent via your customer database
  6. Paid: Visitors that arrive on your site via paid channels, e.g. Google AdWords, Facebook Ads, etc.

User Engagement

In addition to how they find your site, it’s also important to examine how visitors behave once they’re there. There’s a number of key user engagement metrics you can measure that will provide powerful insight into how visitors behave on your site.

  • Bounce rate
  • Time on site
  • Average pages per visit
  • Percentage of returning visitors
  • Frequency of visits
  • Days since last session
  • Audience engagement rate

Step Two: Tracking the Most Important Stuff

Now that the foundational tasks are out of the way, it’s time to finally dig into setting up your Google Analytics Ecommerce strategy. For the sake of time, we’ll move past the barebones basics of GA setup to the slightly more technical parts. If you’re looking for the true ‘basics’ I recommend the official Google Support guidelines. As an important note, if you want to enable Enhanced Ecommerce, be sure to implement Universal Analytics on your site. 

The typical structure of a Google Analytics account is as follows:

google analytics ecommerce tracking

As you can see, your Google Analytics account is split into three different levels: Account, Property, and View.

Account Level

This is your access point for Analytics. The Account Level is primarily used for managing user access.

Properties Level

A property is a website, mobile app, or device. A Google Analytics account can contain one or more properties. However, you should avoid using multiple GA properties if not necessary as extra properties slow down your page.

If you have your blog and store site set up under separate domains, you should use the same Property and tracking code for both. This is called cross-domain tracking and can be a bit tricky to set up. Google does a pretty good job of explaining the particulars, so if you want more information I’d suggest heading over to Google Support.

View Level

A view is the access point for reports. This is where you’ll see the data that is collected and included in reports. GA allows you to create up to 25 views with filters applied. Each property should include at least three different views, which brings us right into the first phase of setup.


Create views

When you create an account Google automatically creates an ‘all website data’ view, but it’s important that you create a few custom views to better segment data.

Raw Data

First, make a raw data view so that you will always have a backup data copy. This will come in handy if you ever run a filter, create a custom report, or your data just gets a little out of whack one day. It ensures that there is always a place to check what is being captured by your tracking code without any changes applied to the data.

The easiest way to do this is to select the automatically generated ‘all website data’ view from the dropdown

google analytics ecommerce tracking

Select ‘View Settings’ and add the word ‘Raw’ to the view name

google analytics ecommerce tracking

Doing this tells that this is the data that you do not want to touch. There should be no filters, IP exclusions, goals, or anything else in this view. The Raw View should have only features that involve collecting data directly from trackers or Google.

Once you’ve created the view, as an ecommerce business, you’ll want to activate Ecommerce, authorize any Google products you have linked, and click save.

Master view

The Master view is the actual view you’ll be using with IP exclusions, etc. To create this view click the down arrow key under the view profile.

google analytics ecommerce tracking

Create a new view and name this ‘MASTER Website Data’ and select the correct time zone.

google analytics ecommerce trackingTest View

Finally, create a third view the same way you created the ‘Master’ view. Name this one ‘Test.’ Fittingly enough, this is the view you’ll use for testing.


Create and apply filters

The next step in your journey to the perfect Google Analytics for Ecommerce setup is to create and apply filters. Filters are used by your various Views to segment data into smaller groups, exclude unwanted data, or search certain pieces of information. Filters can be created at the Account or View level. To create a new filter navigate to the Admin interface. On the view column select Filters then click on the +Add Filter button.

google analytics ecommerce trackingExclude Internal IP

Chances are your employees visit your website a lot. Even if you have a small team these visits can really skew your ecommerce data. Use this filter to tell Google what you don’t want to track. This includes traffic from internal employees as well as that from third party companies or agencies that you work with.

First, create a new filter follow the step above then:

  • Name the new filter “Exclude Internal IP”
  • Select Custom under Filter Type
  • In the Filter Field dropdown, select IP Address
  • In the Filter Pattern field, use regular expression to enter all IP addresses you would like to exclude. Separate each IP address with a pipe “|” symbol.
google analytics ecommerce tracking
  • Choose which views you want to apply the filter to. You should select every view, other than “raw”
  • Click Save to create the filter

google analytics ecommerce trackingFilter out spam and bots

Fake traffic results from one or more hits to your website generated by a program or bot, rather than a living human being. It can get pretty pesky when it comes to reporting. Luckily with Google Analytics filters you can minimize or possibly eliminate the negative impact of fake traffic on your reports.

The easiest way to go about filtering spam and bots is to select “View Setting” from the Admin tab. From there check the box marked “Exclude all hits from known bots and spiders.”

google analytics ecommerce trackingApplying this filter this allow Google to block some spammers. It won’t solve all of your problems, but should mostly get the job done. For more advanced information, I recommend checking out Moz’s guide.

Filter for Device Category

To see data from users only using a specific device create a filter for each device type. Create a new filter and name it “Mobile Only.” Under Filter Type selected Custom, click Include, then select Device Category under Filter Field, finally, choose Mobile and save.

google analytics ecommerce tracking

This will create a mobile only filter. Repeat the same pattern for Desktop.  

There are far more filters you can apply, as well as segments. Segments are basically mini filters that are less permanent and only influence reporting data on the session or user level. For more information on the kinds of filters you can apply, check out this post by Lunametrics. As far as segments go, navigate over to Analytics Help to set them up.


Exclude self-referrals

Self-referrals happens when your domain (or that of third-party payment options) shows up in referral reports. This can cause acquisition data to appear inflated, and conversion data to be misrepresented.

Excluding yourself and third-party payment providers from the referral list will ensure that your data is accurately recording where visitors are coming from. If not, most conversions might be attributed to the payment provider which prevents you from seeing the actual source of the conversion.

So, to property exclude this data you must manually enter your domain and that of your payment providers to the Referral Exclusion List.

From the Admin page, select Property followed by Tracking info and  Referral Exclusion List:

google analytics ecommerce trackingClick “+Add Referral Exclusion” and add your domain and that of your third party payment provider (PayPal, Apple Pay, etc.). You may also want to consider adding the domain of your ecommerce platform if you use one (Shopify, BigCommerce, Magento, etc.).


Connect Search Console

Once you’ve filtered out all that data you don’t want to see in your GA reports, you’ll now need to tell Google what data you do want to see. Luckily, if you’ve followed the first step above, you’ve already got a pretty good idea of what you hope to glean from Google Analytics.

To works towards the ultimate goal of increasing conversions, you first need to sign up for and connect Google Search Console.

This will allow you to see which keywords are bringing visitors to your site, which pages they’re viewing, and how that affects your conversion rate. Data from Search Console is segregated from your other reports, however, it is the best way to gain insight on keywords that are driving search impressions and clicks that lead to visitors.

To set it up first go to Google Search Console. You’ll need to log in with your GA credentials. From there click the ‘Add a Property’ button at the top of the page.

google analytics ecommerce trackingNext, enter the URL of your website and click continue. As you already have a Google Analytics Tracking ID installed, all you’ll have to do is click the ‘Verify’ button and it’s ready to go!


Activate site search

If you have a search function on your website, you can use it to find important keyword. Which can ultimately improve your SEO efforts, while also exposing important user behavior metrics. You’ll be able to track what people are searching for on your site, and whether or not they’re finding it.

There are a few ways to configure Site Search, that depend on what’s driving your website’s search function.

If you’re using an ecommerce platform, such as Shopify, you’ll be able to configure Site Search reports using a query parameter.

Start by performing a search on your store and look at your URL. It should look something like one of these three options:

If your URL looks completely different, chances are you’ll need to use another approach for configuring Site Search reports. You can find more information about these methods here.

For those of you lucky readers who can use the query parameter method, the next step turn on “Site Search Tracking.” You’ll do this once again from the ‘Admin’ section. Next, find the view you want to configure and click on the ‘View Settings’ option. Scroll down to the ‘Site Search Settings’ area and switch ‘Site Search Tracking’ on.

google analytics ecommerce tracking

Next, enter query parameter used for search queries in the Query parameter box. You’ll find this variable in the URL you identified while performing a search on your site.

In the first example, we can see ‘q’ is the query parameter because it’s between the question mark and the equals sign. This is the query parameter and we’ll enter it into the designated box.

Finally, check ‘Strip query parameters out of URL.’ This will prevent your search from showing up in your content reports.

Finally, because Site search settings are view-level, you’ll need to repeat this process on all views.


Track goals to define and measure success

A Goal in GA is a set of criteria you define to measure if visitors are performing certain actions on your site. As we already determined, for ecommerce companies, the overarching goal is likely to be purchases. However, Google Analytics Goals can also be useful to track all of the micro-conversions as well. You can opt to set goals that help you track your performance in regards to one of your KPIs or performance targets.

A few common micro-goals you can set is to track are number of newsletter sign-ups, or visits to a particular page.

The key is to keep it simple and only track things that will actually help understand your progress towards your overarching business goal.

Goals are set in the View level of GA. On the Admin page select ‘Goals’ in the View column.

You have two options: ‘+New Goal’ or ‘Import from Gallery’

The Import from Gallery option will show you different pre-made Goals that were submitted by users and provided by Google. This is a great option if you’re in need of some inspiration.

If you want to create your own Goal, click on +New Goal. From there you’ll be given a choice of 11 common templates and Custom.

The template option will prefill the name, and automatically select the most appropriate type of action for the Goal you’ll be tracking.

If going the Custom option, you’ll have to choose a Goal Type. There are 4 types of goals to choose from. They include:

  • Destination: A specific page that your visitor must hit.
  • Duration: The length of time your visitor’s session must last.
  • Pages/Screen per session: The number of pages your visitor must view.
  • Event: An action a visitor must complete

To track a purchase goal, you first need to give your goal a name in the Goal description section. Choose ‘Destination’ as the Goal Type and click Continue.

google analytics ecommerce trackingIn ‘Goal details’ choose ‘Regular expressions’ and enter the URL of the visitor’s final page visit after making a purchase. This should be some kind of thank you page or purchase confirmation. Keep Value and Funnel switched off.

google analytics ecommerce trackingClick ‘Verify this Goal’ to ensure that you’ve entered the destination URL correctly, and click Save.


Measure demographics and interests

Google Analytics can help you identify key information about your customers such as age, gender, tests, habits, hobbies, and more.

To configure Demographics and Interest reporting go to Property Setting from the Admin page. Turn on ‘Enable Demographics and Interest Reports.’

google analytics ecommerce trackingStep Three: Enhanced Ecommerce Tracking

By now you’ve set up your Analytics account to track a ton of general insight. However, as an ecommerce business, no GA set up would be complete without enabling Enhanced Ecommerce tracking. This feature allows users to track custom ecommerce analytics metrics and dimensions, such as product delivery time, the results of internal promotions, and individual product margins. When setup correctly, you will also be able to track customer data from start to finish--a pretty big deal if you care at all about UX, shopping behavior analysis, and more.

You can also opt to install Basic Ecommerce tracking which will give you fewer reports and an overall less holistic view of your user engagement.


Installing Enhanced Ecommerce

The ins and outs of installing Enhanced Ecommerce tracking can get a bit technical and will depend on what ecommerce platform you use/if you use one.

If you are using an ecommerce platform, set up is far easier than the DIY option. Shopify, WooCommerce, and Magento all offer an ‘out of the box’ Enhanced Ecommerce plugin that essentially requires you to flip a switch and let the good times roll.

On the other hand, if you’re not using an ecommerce platform, you’ll likely need a web developer who understands javascript. For the full DIY version (or if you happen to be a developer), you can follow these 3 steps:

  1. Implement Universal Analytics
  2. Use Google Tag Manager to add the ec.js tracking code to each and every page of your website
  3. Enable Enhanced Ecommerce for each view you want to use

Luckily there are tons of great guides for setting up Enhanced Ecommerce, so I’ll leave the nitty-gritty to these guys: Google Analytics Help Center, Shopify, and Kissmetrics.


Track shopping behavior

The Shopping Behavior report that you’ll be able to access once you’ve enabled Enhanced Ecommerce will show you concrete stats on how many customers moved from one stage of your sales funnel to the next.

The Shopping Behavior report shows how many sessions occurred during a set period of time, and how many of those quickly left your site without shopping. You’ll see the number of sessions with product views, how many users left without adding anything to their cart, and how many ultimately abandoned items in their cart. Finally, the shopping behavior analysis report will tell you how many users initiated checkout, how many abandoned checkout, and ultimately how much sessions ended in a purchase.

You can find this report by navigating to Conversions > Ecommerce > Shopping Behavior.


Set up custom metrics and dimensions

By default, Enhanced Ecommerce comes with a group of predefined dimensions and metrics. These represent information about your products, such as product name, brand, price, etc. If you want to tell GA any extra information that doesn’t match these default metrics, you can do so through the use of custom dimensions and metrics.

Custom dimensions

For example, if you own a fashion ecommerce business, it may be a good idea to pass product sizing information to GA. You can do so from the Property column within Admin. Click Custom Definitions followed by Custom dimensions.

Click the +New Custom Dimension button and add a name. Next, select the Scope, which in this case will be ‘Product.’

Check the Active box to start collecting data and see the dimension in your reports. Finally, click Create.

google analytics ecommerce trackingCustom metrics

Custom metrics are also used to pass additional product-related metrics to GA. This is useful if you want to add the product margin for each product. This will allow you to calculate the real revenue you generate.

Again, from the Admin panel click Custom Definitions followed by Custom metrics and +New Custom Metric. Give your metric a name and select Product as the Scope again. To track profit margin, your Formatting Type should be set to Currency. Leave the other two boxes blank, set to active and click Create.

google analytics ecommerce trackingModify your tracking code

After you create custom dimensions or metrics, you must also modify your site’s tracking code. Again, this may need to be completed by a qualified web developer.

What Now?

If you’ve followed the steps above you should be well on your way to Google Analytics success. There’s plenty more for you to discover, especially about Enhanced Ecommerce reporting, however, the massive amount of extra data available can quickly become quite overwhelming.

As a rule of thumb at this stage, it’s best to keep things simple. Stick with the reports that you know you’ll use and will provide benefit right from the get-go. Don’t get so caught up in the number of things you can track that you distract yourself from what’s really important. Make sure to keep your goals in mind and always working towards that overarching objective.