Calculating Gross Profit with Google Analytics

Calculating Gross Profit with Google Analytics

Understand gross profit

Top line revenue i.e. every dollar that comes into the business, is a useful number. It should reflect how your marketing and sales teams are doing. If you’re running a marketing campaign, you should see an increase in top line revenue but if you only look at top line revenue you don’t take into account how much is spent on the product itself, how much has spent on promotions, and how much is spent on shipping and other costs.

You could see an increase in your top line revenue and not become more profitable. You might have to pay an employee overtime or your ad campaign brought in a ton of customers but they didn’t pay for themselves. These numbers can hide serious problems and first-time business owners may miss the signs because tools like Google Analytics have to be configured to show those exact numbers. We can configure Google Analytics to show a more useful number, and that’s gross profit. The difference between gross profit and gross revenue is that gross profit includes the cost of good sold, also called COGS.

COGS is how much it costs to acquire or create the products. This includes the materials used to create the products and the hourly wage of anyone working directly on that product. Essentially, COGS includes parts and labor. It doesn’t include fixed costs such as rent, insurance, or advertising.

Looking at gross profit instead of gross revenue lets you create a successful pricing strategy. It also allows you to look at your business as a machine that can improve efficiency in many tiny ways like sourcing cheaper parts or improving employees’ efficiency. Looking at your business from every angle is a much better strategy than always trying to sell more.

Now that we have the theory down, let’s set this up in Google Analytics so you can see your gross profit at a glance.

Add a custom metric

To see the cost of goods data in Google Analytics, we’ll have to add, track, process, and then display that data. The first is configuration, where we create space for the data and assign some basic properties. The second is collection, which is when we send Google Analytics this data. The third is processing, which is where we can do optional processing, and the fourth is reporting, where we build reports and display this new data.

We’ll start by going through the first part of this, configuring the data. Once you’re logged in to Google Analytics, you’ll see a list of all the accounts that you have access to. I’ll open up this one right here. Under each account, you’ll see a list of properties, and under each property, you’ll see a list of views. Under this property, I have three views. For many sites, they have just one account, one property, and one view, and that’s totally fine. When I work with Google Analytics, I like to make sure there’s an additional test view.

Before we can track data, we have to define what that data is and what it should look like. To do that, we’re going to have to add a custom definition. A custom definition works just like any of the default definitions in Google Analytics which are things like page views, browser information, and time on the page. Anywhere where you see a default definition, you can have your own custom definition.

Custom definitions come in two flavors. The first is custom dimensions, which are non-numeric pieces of data such as the city you live in. The second flavor is custom metrics, which are numeric pieces of data, like pages per session. In our case, because we’re going to use numeric data, which is the cost of goods, we’re going to want to use a custom metric.

Let’s go back to our Google Analytics account, and add that. As you can see here, I have a TESt and a TEST2 view. TEST has been collecting data for a while, and TEST2 is what we’ll be working on together through this post. I’ll be going back and forth between them just to show you what it looks like when you have enough data.

Let’s go to Admin and then go to Property, and then scroll down to Custom Definitions, and then Custom Metrics. Click New Custom Metric. There are a few fields we’re going to have to fill out here. The first is Name. I’ll call it Cost of Goods. The next field is Scope. Scope is basically how you want to store and access this data. If it’s related to a specific page, you’d want to use Hit, but because our data is related to a product, we want to change the Scope to Product. The next field is Formatting Type. There are three choices here: Integer, Currency, and Time. For Cost of Goods Sold, since it comes in dollars and cents, we’ll stick with that and set it to Currency.

Then there are two optional fields: Minimum and Maximum Value. In computer science, there’s an expression that goes, “Garbage in, garbage out,” meaning, if you allow bad data to get into your program, you will always get back data out, which is why I always set sensible defaults.

Let’s set the DataSet default to 0, and we’ll set a maximum as well. If the most expensive product we have on the site is $100, the cost of goods sold shouldn’t be anywhere near that. I’ll just set it to 200 just in case I later add a product slightly more expensive. This way, if someone misplaces a decimal point, we don’t have a cost of goods set to 10,000. Lastly, make sure the Active checkbox is checked, and then click Create. This will create the custom metric. Now we have a place where we can store data.

The next step is to actually track that data.

Import cost of goods (COGS) data

After you create a custom metric in Google Analytics, you’ll be taken to a screen like this. It will show you how to send that custom metric to their service. The code can be included within the snippet you already have on your website to send to Google Analytics.

When you do, you just have to replace this value here with the actual number that you want to send to Google Analytics. This is a good solution for nonsensitive information. If you wanted to track the subscriber level and send that to Google Analytics, that would be fine, but cost of goods data is very sensitive.

You don’t want your competitors to crawl through your website and see how much profit you’re making with each purchase. The could use that data to out-price you and put you out of business. Because the data is sensitive, and because it doesn’t change very often, we’re going to upload it directly to Google Analytics through their interface. Let’s click Done to leave this screen. Then find the screen where we can upload our data. In the sidebar underneath Custom Definitions, we’ll see Data Import. I’ll click that and then scroll up.

If you already have data import, you’ll see something listed right here. If not, click on New Data Set. We can upload all sorts of data. We want to upload cost of goods data for products, so click on Product Data and then Next Step. The name is something that’s just for you, so use anything you want. I recommend using the same you used before and then adding upload or data upload to keep everything straight.

So, I’ll name it Cost of Goods Data Upload. If you see the drop-down for Enabled View, make sure that you select the appropriate view. In our case, we’re using TEST. Then click Next Step. Now we’re setting up the schema. In this case, the schema defines how the data will be organized. The key is the most important value, and I suggest leaving it as is. It basically identifies the products by an SKU.

There are other ways of defining unique products, but this is the easiest way and it requires no additional programming. Just make sure that your e-commerce platform has a SKU set for each project. Under Imported Data, we can tell Google Analytics what type of data we’ll be uploading. Click on the drop-down and under Custom Metrics, find the custom metric we created earlier, Cost of Goods. For overwriting hit data, that should be a problem, but let’s just set it to No just to be sure.

Let’s click Save. We’ll see a bit of text that tells us that the Data Set has been created, and we can now upload our data. Click Get schema. Google Analytics tells us exactly what headers to use in a CSV file. We could copy these manually, but I would hate to have a copy paste error. I’m going to download the schema template. Then click Done.

Let’s take a look at this document. It’s basically an empty spreadsheet with the headers already set. For our purposes right now, we just want to add one product SKU, and one value, just for testing purposes. However, I have seen some weird SKU values. Some e-commerce systems, especially ones designed for digital products don’t always have an SKU, and they might use some sort of internal ID instead.

To see what’s already being sent to Google Analytics, let’s go to Reporting in the top navigation. Now, I just turned on e-commerce tracking for this view. If you just turned it on as well, you might not see any SKUs because there haven’t been any purchases. I’m going to temporarily go to the view that’s been running for a few weeks. Then I’m going to click on Reporting, Conversions, E-commerce, and Product Performance.

For testing purposes, copy one of these SKUs and put that in your spreadsheet, and then add the cost of goods data in the next column. I’ll just remember 287, go over here, 287, and for the cost of goods we’ll just make up a number. I will say 10. Let’s save this. You may see a notice from Excel that says this, and just click OK or Continue. Let’s go back to our Data Import.

We’ll click Done here, and then we’ll see our Data Import right here. Let’s click Manage uploads, and then click Upload file. Then upload the file you just saved. Upload. Once you do this, the test file should be uploaded almost instantly, and when it’s done, you’ll see a Pending status. In a second or two it should change to Completed. When you only have one row, this will only take a couple of seconds.

If you do this with a CSV with thousands of rows, it could take a little bit longer. At this point, we’re done uploading our data.

Calculate gross profit

We need to tell Google how to process this data. In Google Analytics under Admin view, we can click on Calculated Metrics, and then click New Calculated Metric. You can add whatever name you want. I’ll call mine Gross Profit. Set the formatting type. You’ll want to make sure it’s set to the same format that we used to create this cusomt metric, so for us we’ll want to make sure to set ours to currency.

Now we can do the fun part, create a formula for Google Analytics. To calculate gross profit we need revenue minus the cost of goods. Just start typing and you’ll notice that things will be selected. In our case we’ll want to use product revenue, subtract cost of goods.

As a quick note, this is a pretty simple calculation, but you can do some really fancy stuff her. Let’s say you sell digital products and setup sell someone else’s work but you get to keep 50% of it. You could do something like product revenue times 0.5, or you could go even further complex than that. But for us, we’re just calculating gross profit, so we just need revenue minus the cost of goods. Whenever you’re done, click Create.

Create report

We have a custom definition. We’ve uploaded our data and with a calculation Google knows how to sue this data. So let’s create a report so that Google can display this information for us. We can do this in two ways. We’ll create a brand new report and then we’ll modify an existing one. Let’s start with the first option. Under customization we’ll click new custom report. We can add a title, something like Gross Profit.

And then we can customize what’s in the report. Right now I’m going to leave the tab as is and I’m going to leave the type to Explorer. This is the default view for Google analytics. If you want a more table-focused few, you can use this one. Or if you want something that’s more geographically-based you can use the map overlay. I’ll go ahead and add a product revenue, gross profit, and just because I want to see you there, cost of goods.

And then under dimension drill downs we have to add product because Google has to know what type of data we’re looking at. And then we can click Save. Since test tube is what we’ve been using to include our data, let’s now head over to my other test view that’s been sitting with the same data for a little while. That way I can show you some actual numbers in the report. You can scroll down, and you can see Product Revenue, Gross Profit, and Cost of Goods all right next to each other.

And you can use all of them to evaluate your marketing and website needs. Building your report from scratch is clear and concise, but it always seems to be lacking some information. That’s why I also recommend customizing an existing report. I’ll go down to conversions, e-commerce, and then product performance. If I scroll down, you’ll see that we have a lot of data right here and I want to customize this report.

I’ll go to customize. I’ll leave most of the stuff as is, but I will add Gross Profit and Cost of Goods. And since I tend to work with products in the digital space, people usually only buy one of anything, so I’ll remove average quantity as that’s not very useful for my clients. And I’ll also click and drag these towards the front.

I’ll scroll down and click Save. I’m switching over to a view that has a report that’s been collecting this data for a little bit. If we scroll down, we can see Product Revenue, Gross Profit, and Cost of Goods, and a few more fields. Now you can find this report under customization and then the name of your custom report. This method doesn’t actually customize the default report. If you want to find the default report it can still be found in the same place.

So if you want to see Gross Profit included in that report, you’ll have to view the custom version of that. Now that we have a bit more data at our fingertips, we can make better decisions for our business.

Conclusion

Now that we have this set up, there isn’t much more to do. It’s pretty much a set it and forget it tool. The one thing that you definitely should do moving forward is to update your data occasionally. This is a manual process. As products get their cost of goods updated, you really should update everything in Google Analytics. Maybe once a month or once a quarter. It really depends on how accurate you need that data to be. Even though this is mostly a set-it-and-forget-it tool, the key is to use the data.

Use it when you evaluate how your promotions are going. If you have a marketing or sales team, they should be using gross profit to determine if a project succeeds or fails. And they should also use it to determine which products to highlight for future promotions. I found that some companies realize they’re losing money on some products and they cut those products entirely. Or some companies, for example, the electronic store that I mentioned in the beginning, use their large ticket items that have a low profitability to get people to buy a ton of accessories which have high profitability.

I really recommend looking at your analytics with profit and not revenue in mind. It makes you aware of the whole machine that can be optimized, instead of just sales. If you want to start thinking about other e-commerce principles, I recommend my WordPress e-commerce course.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *