• 1. About this Book
  • 2. 10 Reasons why Ecommerce Businesses Need to Have Google Analytics Set Up Correctly
  • 3. Quick Overview of Your Google Analytics Admin - Before You Set Up Your Ecommerce
  • 4. Setting Up Your “All Web Site Data” View in Google Analytics
  • 5. What the Heck are Parameters... And What do I do with the "Exclude Query Parameters" Field in Google Analytics?
  • 6. Adding Filtered Google Analytics Views Gives You Access to Better Marketing Data
  • 7. Setting up an “Include My Domain” Filter in Google Analytics
  • 8. Using Google Analytics Filters to Rid Yourself of Rage-Inducing Referral Spam
  • 9. Formulating Your IP Address Filter in Google Analytics
  • 10. Ensuring that Your Google Analytics Data is Accurate by Applying Lowercase Filters
  • 11. How to Remove Slashes From The End of your URLs in Google Analytics
  • 12. Fixing the Problem of Parameters in your Ecommerce URLS in Google Analytics
  • 13. Acquiring Your Ecommerce Store’s Unique Parameter List for Google Analytics
  • 14. How to Turn your Ecommerce Parameters into Custom Dimensions in Google Analytics
  • 15. Using your Parameter Custom Dimensions to Discover Ecommerce Opportunities
  • 16. Key Google Analytics Settings You Might Have Overlooked for your Ecommerce Configuration
  • 17. What are the Google Analytics Ecommerce Settings For and How are They Set Up?
  • 18. How to Turn on Ecommerce Tracking in Google Analytics
  • 19. Google Analytics Enhanced Ecommerce on popular Ecommerce Platforms
  • 20. Manually Adding Google Analytics Standard Ecommerce Transaction Tracking Code
  • 21. Manually Adding Google Analytics Enhanced Ecommerce Transaction Tracking Code
  • 22. Implementing Enhanced Ecommerce Features to Collect Game Changing Data For Your Ecommerce Store
  • 23. How Do You Use the Ecommerce Reports Built into Google Analytics?
  • 24. What is the Google Analytics Ecommerce Overview Report and What Should You Use It For?
  • 25. What is the Shopping Behavior Report and What Should You Use It For?
  • 26. The Importance of the Checkout Behavior Report in Google Analytics
  • 27. What is the Product Performance Report Used for in Google Analytics?
  • 28. This post has been deleted
  • 29. How can you see Individual Ecommerce Transactions in Google Analytics?
  • 30. What is the Time to Purchase Report in Google Analytics Used For?
  • 31. Deep-dive your Product Sales with the Google Analytics Product List Report
  • 32. Setting Ecommerce Goals in Google Analytics and Why This is So Important
  • 33. Adding Your Ecommerce Goals to Google Analytics
  • 34. Using Google Analytics Goals to Boost Your Ecommerce Conversion Rate
  • 35. Using the Model Comparison Tool in Google Analytics
  • 36. Segmenting Users - A Powerful Tool for Providing Data Insights
  • 37. Building Segments Using the Shopping Behavior Report
  • 38. How to Use the Segment Builder in Google Analytics
  • 39. How to Build Specific Criteria using Google Analytics' Segment Builder
  • 40. Google Analytics Segment Examples to Enhance Your Ecommerce Sales
  • 41. How to use Segmentation Analysis to Identify Opportunities and Increase Conversion
  • 42. Making the Most of the Demographics of Users When Looking at Ecommerce Data
  • 43. Google Analytics Segmentation Example - Transacted vs Did Not Transact
  • 44. Taking your Segmentation Analysis Further
  • 45. Bonus: Six Reasons Why Your Ecommerce Store Needs Google Tag Manager
  • Petra's Google Ads Agency

    Navigate The Blog

    Archives By Category
    Archives By Date

    Connect With Petra

    Learn From Petra

    Manually Adding Transaction Tracking Google Analytics

    Manually Adding Transaction Tracking For Google Analytics Enhanced Ecommerce Framework

    The tracking codes used by Google Analytics can get a bit complicated, especially if you’re not a developer. I’ll do by best to explain in this article how it all works.

    There are two eCommerce frameworks that you can use in Google Analytics – Standard Ecommerce and Enhanced Ecommerce. This article will discuss the background information along with some examples from Enhanced Ecommerce. If you are using Standard Ecommerce then please go to the relevant article.

    Essentially, if you are using the Google Analytics with Ecommerce turned on, you want to include transaction data with every transaction.

    To do this, you will typically generate a post-transaction “thank you” page, which is intended to be seen by all customers as soon as they purchase. The tracking code will be placed on that page.

    Ecommerce tracking is executed in three distinct steps.

    Firstly, the website’s “server-side” code is responsible for working out the price, the quantity, the tax, shipping etc. (This is often written in PHP, but may be written in another language – it doesn’t really matter). This website code contains instructions that write the Google Analytics tracking code on to the HTML page, or alternatively it might just list all the data values so that it can be dynamically created in Javascript. Irrespective of which language is used to write the website pages, the Google Analytics Ecommerce tracking code will be written in Javascript because that is the language that Google Analytics uses to send data.

    Once the thank-you page has loaded, the HTML page will have been rendered with a Google Analytics tracking code. This tracking code will be updated with all the values that the eCommerce server has sent to the page. The code will include a “send” command that will send the data to Google Analytics.

    As the page is rendering the Google Analytics tracking code will execute and send the data over to Google Analytics. This is why it is important that the Google Analytics tracking code is placed as high up in the page as possible, in order for it to have the opportunity to finish executing before your website visitor closes their browser window.

    Good to Know: You can manually add transaction data to your website even if you don’t implement all the different options from the Enhanced Ecommerce Framework.

    Now lets look at how this is done with Google Analytics Enhanced Ecommerce framework. If you are using the Google Analytics Standard Ecommerce framework then skip to the relevant article.

    In the same way as with the Google Analytics Standard Ecommerce framework, you can add your Enhanced Ecommerce tracking code to a post-transaction “thank you” page.

    The Google Analytics Enhanced Ecommerce tracking code is made up of two components – the Action data and the Product data. We will now look at these two aspects of the tracking code in more detail.

    Action Data

    In the table below, you can see the format for action data. A transaction is considered an action in the Enhanced Ecommerce Framework. Actions are generic and can be used for more than just transactions, so some of the options listed are not relevant for transactions.

    Google Analytics. Retrieved from https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce

    Here’s a bit of a summary:

    • The Transaction ID is a required field. This will be a generated ID made up of letters and/or numbers which will uniquely identify the transaction.
    • The Affiliation is an optional field, and is the name of your store. It is useful to include if you have more than one eCommerce store sharing the same Google Analytics property, or if you have more than one department, each with its own shopping cart.
    • The Revenue is an optional field. It tells you the total amount that your customers are paying for the transaction, irrespective of how many items are being purchased; i.e. it is the final total price. Google Analytics can determine the amount from the total revenue of the products, if the revenue is excluded from the transaction.
    • Shipping and Tax are optional fields, but are good to add if you know these details.
    • Coupon enables you to list a coupon that was used with a transaction.
    • List, Step and Option are optional fields that would not typically be used with a transaction action.

    Product Data

    In the table below, you can see the format for product data. A transaction does not require products, but it greatly enhances the functionality of the data if you include them.

    Google Analytics. Retrieved from https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce

    Here’s a summary of the product data:

    • The Product ID is a required field that uniquely identifies a product, i.e. it is a product code or SKU.
    • The Name is a required field that describes the human readable name of the product.
    • The Brand is an optional field that describes the brand of the product.
    • The Category is an optional field that describes which product category this product belongs to.
    • The Variant is an optional field that describes which variation of a product this is.
    • The Price is an optional field that lists the unit price for the product. While it is optional, it should always be included for a transaction.
    • The Quantity is an optional field that lists how many of this product was purchased in this transaction. While it is optional, it should always be included for a transaction.
    • The Coupon is an optional field that is used for a coupon code that is associated with the product rather than a transaction.
    • The Position is not relevant for transactions.

    Adding a single transaction via Enhanced Ecommerce is quite straightforward, so you end up with a fairly simple piece of code that can then be added to your transaction thank you page.

    Important note: You will see examples of Enhanced Ecommerce code written for Google Tag Manager as well as Google Analytics. These are very similar in format, with a few notable differences. Google Tag Manager code is pushed to the Data Layer whereas Google Analytics code is pushed to Google Analytics directly. We won’t be covering Google Tag Manager in this article series, but Google Tag Manager is my area of expertise so please contact me if you require assistance with Google Tag Manager.

    Here is what a completed example using Enhanced Ecommerce Framework would look like:

    Step 1: Let Google Analytics know that we will be sending Enhanced Ecommerce data.

    Step 2: Add the product data.

    Step 3: Add the action data.

    Step 4: Send it all to Google Analytics so that it turns up in your Google Analytics Ecommerce reports

    Effectively adding tracking data to your thank-you pages will take a bit of getting your head around, especially if you don’t come from a developer background. It is well worth the effort to get it done however, as adding Ecommerce data to your Google Analytics reports will prove to be invaluable for your business.

    Want to get 8-10X ROAS from Google Ads?