Setting up Google Analytics for enhanced e-commerce tracking involves several steps, from configuring your Google Analytics account to implementing the necessary tracking code on your website. Enhanced e-commerce tracking provides deeper insights into customer behavior and e-commerce performance, allowing you to analyze product performance, shopping behavior, and sales conversions. Here’s a step-by-step guide to set up enhanced e-commerce tracking in Google Analytics:
1. Set Up Google Analytics Account
If you don’t already have a Google Analytics account, you’ll need to create one.
- Sign Up for Google Analytics: Go to Google Analytics and sign in with your Google account. Follow the prompts to create a new account.
- Create a Property: Set up a new property for your website. Enter the website name, URL, industry category, and time zone.
- Get Tracking ID: Once the property is created, you’ll receive a tracking ID (e.g., UA-XXXXX-Y). You’ll need this ID to implement tracking on your website.
2. Enable Enhanced E-commerce in Google Analytics
- Access Admin Settings: Go to the Admin section of your Google Analytics account.
- View Settings: In the View column, select the view where you want to enable enhanced e-commerce. Click on “E-commerce Settings.”
- Enable Enhanced E-commerce: Toggle the switch to enable “E-commerce” and “Enhanced E-commerce Reporting.”
- Save Settings: Click “Save” to apply the changes.
3. Implement Enhanced E-commerce Tracking Code
Enhanced e-commerce tracking requires adding JavaScript code to your website to send e-commerce data to Google Analytics. This involves using Google Tag Manager (GTM) or directly modifying your site’s code.
Using Google Tag Manager (Recommended)
Google Tag Manager simplifies the process of managing and deploying tracking codes on your website.
- Set Up Google Tag Manager: If you haven’t already, create an account and container for your website in Google Tag Manager.
- Install GTM Code: Add the GTM container code to your website’s HTML. This code should be placed in the
<head>
and<body>
sections of your website. - Create Tags for Enhanced E-commerce:
- Pageview Tag: Create a new tag for tracking pageviews.
- Tag Configuration: Select “Google Analytics: Universal Analytics.”
- Track Type: “Pageview.”
- Google Analytics Settings: Enter your tracking ID.
- Triggering: Set the trigger to fire on “All Pages.”
- E-commerce Tags: Create additional tags for e-commerce actions such as product impressions, clicks, detail views, add-to-cart, remove-from-cart, checkout, and purchases.
- Use the “Google Analytics: Universal Analytics” tag type.
- Track Type: “Event.”
- Enable Enhanced E-commerce features: Toggle “Use Data Layer.”
- Set up triggers for each e-commerce action accordingly.
- Pageview Tag: Create a new tag for tracking pageviews.
- Data Layer Implementation: Ensure your website’s data layer is correctly configured to pass e-commerce data to GTM. The data layer should include information about products, transactions, and user actions.
- Example of a product detail view data layer:
javascript
dataLayer.push({
'event': 'productDetail',
'ecommerce': {
'detail': {
'products': [{
'name': 'Product Name',
'id': 'Product ID',
'price': 'Product Price',
'brand': 'Product Brand',
'category': 'Product Category',
'variant': 'Product Variant'
}]
}
}
});
- Example of a product detail view data layer:
- Publish the Container: Once all tags and triggers are configured, publish the container in GTM to start tracking enhanced e-commerce data.
Direct Code Implementation (Alternative)
If you’re not using Google Tag Manager, you can implement enhanced e-commerce tracking directly in your website’s code.
- Include Analytics.js: Ensure the Google Analytics
analytics.js
library is included on your website.html<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', 'UA-XXXXX-Y', 'auto');
</script>
ga('require', 'ec');
- Send E-commerce Data: Use the
ec.js
plugin to send e-commerce data. For each e-commerce action (e.g., product impression, add-to-cart, transaction), add the corresponding code to your website.- Example of a product detail view:
javascript
ga('ec:addProduct', {
'id': 'Product ID',
'name': 'Product Name',
'category': 'Product Category',
'brand': 'Product Brand',
'variant': 'Product Variant',
'price': 'Product Price'
});
ga('ec:setAction', 'detail');
ga('send', 'pageview');
- Example of a product detail view:
4. Verify Enhanced E-commerce Tracking
After implementing the tracking code, it’s important to verify that data is being collected correctly.
- Real-Time Reports: In Google Analytics, go to the Real-Time reports to see if e-commerce data is being recorded as you perform actions on your website.
- Debugging Tools: Use debugging tools like Google Tag Assistant and GTM’s preview mode to troubleshoot and verify your implementation.
- E-commerce Reports: Check the E-commerce reports in Google Analytics to ensure data is populating correctly. Navigate to Conversions > E-commerce and review various reports such as Overview, Shopping Behavior, Checkout Behavior, and Product Performance.
Conclusion
Setting up Google Analytics for enhanced e-commerce tracking involves enabling e-commerce settings in your Analytics account, implementing tracking code through Google Tag Manager or direct code modification, and verifying data collection. By following these steps, you can gain comprehensive insights into your e-commerce performance, helping you make data-driven decisions to optimize your online store and improve sales.