For all of the metrics we focus on in the marketing world – organic vs. paid visits, pageviews, keyword rankings, load time, you name it – all of this is irrelevant to most people. I don’t go to work because I REALLY like seeing organic visits on the dashboard or I REALLY like writing title tags.  My clients don't pay Digital Third Coast because they think George is a cool dude and they like hearing my soothing voice rant about soccer and organic visits on the phone. Everything we do as digital marketers comes down to one thing. To quote the legendary Wu-Tang Clan, Cash Rules Everything Around Me. 

I'm not a business man, I'm a BUSINESS, MAN.

 

Now, if you're a B2B company and do not sell things through your website, quantifying this can be a difficult task (but it's possible). But, if you're in ecommerce, you're in luck - because we can track where that cold hard paper comes from. Not only total revenue either - we can segment by channel, by product category, by time, by day; we can even tell you how much organic search customers spent on shipping with your company. We have full control over the ecosystem and have all the data needed to make critical marking decisions. Sounds pretty cool, right? "But Barry, I don't know how to do that!" Well, I do. Sit down, children, as I take you through a journey filled with rap song references while I explain how to set up ecommerce tracking for your business.

Mo' Tracking, Mo Problems

Before you go and get all gung-ho about this, take it with a grain of salt. You wanna track these stacks of paper you're making? Mo' Tracking, Mo' Problems, homeboy.  

"I don't know what, they want from me, It's like the more money we come across, The more problems we see" - Puff Daddy describing my life with ecommerce tracking

 

There are a few key things you need to be aware of when it comes to setting up ecommerce tracking on your website. Let's go through them.

Know Where to Add the Code

This is going to vary based on your exact platform, but generally this code gets installed to the order confirmation page. It's usually something like /finishorder.php or order.html or another template file of that nature. I HIGHLY suggest referring to your website developer who manages your shopping cart installation or calling your Shopping-Cart-As-A-Service provider when trying to implement this code.

Shopping Cart as a Service Programs

Speaking of which, are you using a Shopping-Cart-As-A-Service program? You're in luck, because when you work with these programs, it becomes much easier to get your e-commerce tracking up and running. These programs also provide their own marketing analytics reports which you can cross compare to your Google Analytics report and ensure that data is accurate. The leading Cart-As-A-Service programs are Shopify, BigCommerce, and Volusion. Unless you are supremely talented with working in WordPress/Drupal/Magento, or you're moving enterprise-level scale of products, I highly recommend using one of these services. They will make your life infinitely easier, and all are designed for small business owners, NOT developers and nerds like me. All three services have great dedicated support departments that will help you change things in your store. Each service provides instructions specific to that platform, found below.

Room for Error?

Finally - it's very unlikely your store report/ledger will match exactly with ecommerce tracking. E-commerce tracking codes aren't the best at handling returns, and they sometimes have problems with third-party payment gateways such as Paypal. Don't stress about cents and a few dollars here or there - as long as it's within a reasonable margin of error, you're good to go.

How to Enable Ecommerce Tracking

You need to enable e-commerce tracking in your Google Analytics account. Once logged in to the View level, select E-commerce Settings in the Admin dashboard and Enable E-commerce. You can turn on enhanced tracking and set up a goal funnel to see abandoned carts and drop-offs in the sales process (but, if you use Shopify/BigCommerce/Volusion, they'll give you these reports and automatically help you manage cart abandonment. Yet another reason to use these services if you're in the ecommerce game). SSL installation is either required or highly recommended when it comes to ecommerce stores. For instance, BigCommerce will not transmit ecommerce data unless there is an SSL applied to the website and shopping cart. Consult with your developer or ecommerce provider for exact advice regarding your cart software of choice.

99 Problems but Analytics Ain't One

00602498639023_640x480_01 Most of my problems are due to women, but none of them are due to Analytics. Maybe me and Jay-Z can trade advice sometime.

 

Let's start diving into the code so you can go rags-to-riches, Jay-Z style. Below we're going to break down the anatomy of a tracking code and explain exactly what it does, and how to modify these variables to fit your particular ecommerce store. This example is based on the ecommerce code provided by BigCommerce - but the general code outline and variables are going to be pretty similar for any platform, be it Wordpress, Drupal, Magneto, Volusion, etc.   Here's the skeleton of a typical e-commerce tracking code

ecommerce tracking code Click to enlarge

 

Part 1- The first part of the script tells the server to run the Google Analytics script. Simple enough — you need to collect the baseline tracking data and have Google Analytics running before you start collecting Google Analytics data. Notice that we're specifying analytics.js which is the call for the Universal Tracking Script. You also want to ensure the standard Google Analytics Universal code is installed to every page on the site except for order confirmation (where you'll be installing this code).

Standard Google Analytics script Click to enlarge

 

  Part 2 still contains your standard Universal Analytics code with one exception - we're loading the Google Analytics profile, but we're also specifying the domain. This is because some shopping carts, such as BigCommerce, actually process the order on a different domain. For example, if you were ordering from a BigCommerce site, the shopping cart isn't on the same domain as your store - it goes to store-xxxx.mybigcommerce.com/order/*****. By specifying the domain in the code we prevent any self-referrals in the e-commerce tracking report. The final part of this section is a directive to run ecommerce.js, which is the standard ecommerce code for tracking in Google Analytics. Note: Your server needs to be configured properly to push data from your server to Google Analytics. If you're using a platform like BigCommerce, this is automatically configured. If you're running a typical WordPress platform with a LAMP stack, the ability to push data to server is determined by how PHP is configured. Consult your developer  

Directive to Google to prepare ecommerce data by running the ecommerce.js script Click to enlarge

 

  Part 3 will be familiar to anyone who's taken a coding class - we need to define our arrays and variables to tell Google exactly what we want to be tracking. This piece of JavaScript specifies addTrans, telling Google Analytics to begin recording transaction data such as order ID and total order amount, and addItem which will track information on a per-item basis such as price of item, SKU or item and quantity ordered.

Starts the ecommerce script and defines the parameters for Transaction and Item data Click to enlarge

 

Part 4 is where we track the transaction-level data. You can really start customizing things and making the data specific to your store. The first part of the code calls out the addTrans function and defines variables for that array, then calls out the Google Analytics ecommerce command to collect this day. In the most basic tracking instances, you're going to collect

  • Order ID or other unique order identifier
  • Revenue - total revenue, tax, and shipping. Product Revenue is not specified in this array because we're going to be collecting the product revenue in the next part of the code, and Google Analytics can total out the product revenue by aggregating this information.
  • Customer Information - usually city, state, and country are specified.

 

Definition of parameters for Google Analytics to collect at the Transaction level Click to enlarge

 

Note: Now the 'fun' part is you can customize this to your specific instances. Do you have a loyalty program? We can add a specification for 'LoyaltyID' and collect that data allowing you to reward repeat customers. Work with businesses that have an Accounts Payable department? We can add a variable for 'AccountPayable' and 'Company' allowing you to track which companies order from you, and invoice them appropriately. There's a lot of different things you can do with this section - think about what data would be valuable to your business, and you can modify this code by adding a variable for it as such.

function addTrans(orderID,loyaltyID,store,total,tax,shipping,city,state,country) ga('ecommerce:addTransaction', { 'id': orderID, 'loyalty':loyaltyID 'affiliation': store, ........

And so forth. Again, consult with your developer/webmaster/E-commerce provider for exact options   Part 5 is the item level data, and just like with the transaction-level data, you can customize this. By default, this array tracks the following components

  • Order ID (allowing you to review orders in GA by associating the transaction with the product)
  • SKU, Product Name, and Price
  • Category (very useful for Google Analytics, seeing top performing categories by channel)
  • Quantity orders
Pulls the item data into Google Analytics Click to enlarge

 

Now, again, you can change this around to fit your needs. Let's say you're a clothing store selling Chicago Fire jerseys because you really like taking money from people who are already depressed enough. We can add variables for color, size, and player (as long as those attributes are reflected on your order confirmation page). Like so:

function addItems(orderID,sku,product,size,color,player,variation,price,qty) { ga('ecommerce:addItem', { 'id': orderID, 'sku': sku, 'name': product, 'size': price, 'color': kitcolor, 'player': player, 'category': variation, 'price': price, 'quantity': qty

The options on the transaction level and item level are limitless, but keep in mind that too much data can be a bad thing - and Shopify/Volusion/BigCommerce already give you these reports. If you're comfortable customizing and this data is going to help you with your business decisions, go for it! But don't feel obligated to go this deep - just having basic tracking already makes you an above-average store owner. Part 6 is close curtain. The code will repeat the Item array for every item ordered and when it hits the end, it runs this directive - send data to Google Analytics and pack it up.  

Directive to send the collected data to Google Analytics Click to enlarge

 

Living in a Tracking Paradise

dbo6g0ggymslu87xoufc TELL ME WHY, ARE WE, NOT TRAAAAAACKING WHEN THE ONES, WE HURT, ARE YOOOOOU AND ME

 

If you want to truly understand your ROI as an ecommerce store, you absolutely need to have ecommerce tracking implemented. You'll better understand how your efforts on paid search, organic search, and even referrals, e-mails, and inbound are affecting your overall revenue. While the overall bottom line is critical, it ties back into these channels — so if ecommerce tracking tells you, "hey, you're selling a lot of this widget on paid but not on organic," that's data you can use to understand your SEO performance and then look at this page and say, okay, we need to revamp this page on the site, make our messaging clearer, do some blogging and possibly make content about this area of the business. It's a hard-knock life as a store owner (and as an SEO who consults for them and used to work for a very large ecommerce provider), but you can make it easier and start improving your efforts with the advanced, specific data that ecommerce tracking affords you. Learn more about how you can measure your digital marketing results with our free ebook, "How Long Does SEO Take?"