So you have a Google Analytics account, but without ecommerce tracking, you’re still not getting the most useful insights to improve your digital marketing. Ecommerce tracking allows you to track website revenue to better understand what products, channels, geographies, and demographics drive the best revenue performance. Setting up ecommerce tracking might seem intimidating, but you can set it up by following the simple steps outlined below.

A few code changes will give you significant insight into your online store. Image via Pexels.

A few code changes will give you significant insight into your online store. Image via Pexels.

Step 1: Creating Your Pixel

Before reading any further, please note that you should have your Google Analytics pixel placed on all pages of your website before implementing ecommerce tracking.

Google does not provide the ecommerce tracking code in the Google Analytics platform—but don’t worry, I’ve laid out step-by-step instructions below to create the pixel. Once the pixel is created, it will need to be placed on the confirmation page the user is sent to after purchasing.

Part 1: Load the ecommerce plugin

ga(‘require’, ‘ecommerce’);

This will need to be placed before you use any of the ecommerce specific functionality.

Part 2: Adding transaction data using ecommerce:addTransaction command

ga(‘ecommerce:addTransaction’, {
‘id’: ‘00123’, // Transaction ID. Required.
 ‘affiliation’: ‘Clothing Store’,  // Affiliation or store name.
 ‘revenue’: ‘18.99’, // Grand Total.
 ‘shipping’: ‘5’, // Shipping.
‘tax’: ‘1.51’ // Tax.
});

Part 3: Adding item data using ecommerce:addItem command

ga(‘ecommerce:addItem’, {
‘id’: ‘00123’, // Transaction ID. Required.
‘name’: ‘Blue Tee Shirt’, // Product name. Required.
‘sku’: ‘ABC12345’, // SKU/code.
‘category’: ‘Women’s Clothing’, // Category or variation.
‘price’: ‘18.99’, // Unit price.
‘quantity’: ‘1’ // Quantity.
});

Part 4: Sending data using the ecommerce:send command

ga(‘ecommerce:send’);

Example of finalized pixel:

ga(‘require’, ‘ecommerce’);
ga(‘ecommerce:addTransaction’, {
‘id’: ‘00123’, // Transaction ID. Required.
‘affiliation’: ‘Clothing Store’, // Affiliation or store name.
‘revenue’: ‘18.99’, // Grand Total.
‘shipping’: ‘5’, // Shipping.
‘tax’: ‘1.51’ // Tax.
});
ga(‘ecommerce:addItem’, {
‘id’: ‘00123’,  // Transaction ID. Required.
‘name’: ‘Blue Tee Shirt’, // Product name. Required.
‘sku’: ‘ABC12345’, // SKU/code.
‘category’: ‘Women’s Clothing’, // Category or variation.
‘price’: ‘11.99’,  // Unit price.
‘quantity’: ‘1’  // Quantity.
});
ga(‘ecommerce:send’);

Step 2: Placing the Pixel

If your ecommerce site performs transactions on the server, you will need to take a few additional steps to complete the pixel (check with your developer). Once the ecommerce code is pulled together, you can add the code to the server-side template and use this to dynamically write the ecommerce data values to the final page.

Note that the finalized pixel should be placed within the existing GA code on your site in-between ga(‘create’, ‘UA-XXXXXX-XX’, ‘XXX’); and ga(‘send’, ‘pageview’);. After the finalized code is on your ‘Thank You’ page, you will need to toggle on ecommerce in your Google Analytics account. You can do this by going to Admin >> View >> Ecommerce Settings. Voila! Revenue and transactions should start pulling in from that point moving forward.