Tracking transactions in Google Tag Manager (GTM) and WooCommerce can provide valuable insights into the performance of your online store and help you make data-driven decisions about your marketing and sales efforts. By setting up tracking for transactions in GTM and WooCommerce, you can track the revenue generated by your store, the average order value, and the conversion rate for your website. In this blog post, we’ll explore the benefits of tracking transactions in GTM and WooCommerce, and provide step-by-step instructions for how to set it up.
Why track transactions in GTM and WooCommerce?
Tracking transactions in GTM and WooCommerce can provide valuable insights into the performance of your online store. By tracking the revenue generated by your store, you can see which products or categories are performing well, and which may need to be improved or discontinued. Additionally, tracking the average order value (AOV) can help you understand how much customers are spending on your site, and identify opportunities to increase AOV through upselling or cross-selling.
Tracking the conversion rate for your website is also important, as it can help you understand the effectiveness of your marketing efforts and identify areas for improvement. By tracking transactions in GTM and WooCommerce, you can see how many visitors to your site actually complete a purchase, and use that information to optimize your website and marketing campaigns.
First process is to add custom JS to your WordPress site to send the Woocommerce data into a format that is easily ready by Google Tag Manager. To do this install a plugin like “headers and footer” or “Code Snippets” and create a Javascript tag that fires on “Entire Site”
Paste the following code:
the effort required to set it up.
// Check if the WooCommerce plugin is loaded
if (typeof woocommerce_params !== 'undefined') {
// Declare a global data layer array
window.dataLayer = window.dataLayer || [];
// Get the transaction data from the WooCommerce plugin
var transactionId = woocommerce_params.order_id;
var transactionTotal = woocommerce_params.total;
var transactionTax = woocommerce_params.tax_total;
var transactionShipping = woocommerce_params.shipping_total;
var transactionProducts = [];
// Loop through the products in the WooCommerce plugin's "order_items" object
for (var i = 0; i < woocommerce_params.order_items.length; i++) {
var product = woocommerce_params.order_items[i];
transactionProducts.push({
'sku': product.sku,
'name': product.name,
'price': product.subtotal,
'quantity': product.qty
});
}
// Push the transaction data to the data layer
window.dataLayer.push({
'event': 'transaction',
'transactionId': transactionId,
'transactionTotal': transactionTotal,
'transactionTax': transactionTax,
'transactionShipping': transactionShipping,
'transactionProducts': transactionProducts
});
}
This code will check if the WooCommerce plugin is loaded, and if it is, it will pull the transaction data from the woocommerce_params object. It will then loop through the order_items object to get data for each product in the transaction, and push the transaction data to the data layer.
Now We Need To Setup Google Tag Manager
- Setting up tracking for transactions in GTM and WooCommerce is relatively straightforward, and can be done in a few simple steps:
- Install the Google Tag Manager plugin in your WooCommerce store. This will allow you to easily send data from WooCommerce to GTM.
- Create a new tag in GTM for your transaction tracking. To do this, go to the GTM interface, click on “Tags” in the left menu, and then click “New” to create a new tag.
- Select “Google Analytics – Universal Analytics” as the tag type, and enter your Google Analytics tracking ID.
- In the “Triggering” section, select the trigger that will fire the tag. For transaction tracking, you’ll want to choose the “WooCommerce – Purchase” trigger. This will ensure that the tag is fired when a purchase is made on your WooCommerce store.
- In the “Variables” section, select the variables that you want to send to Google Analytics. For transaction tracking, you’ll want to include variables such as the transaction ID, the transaction value, and the product name.
- Save and publish your tag.
Test your transaction tracking to make sure it’s working correctly. To do this, make a test purchase on your WooCommerce store and check the Google Analytics Real-Time reports to see if the transaction is being recorded.
Conclusion
Tracking transactions in GTM and WooCommerce can provide valuable insights into the performance of your online store, and help you make data-driven decisions about your marketing and sales efforts. By setting up tracking for transactions in GTM and WooCommerce, you can track the revenue generated by your store, the average order value, and the conversion rate for your website. While setting up tracking for transactions in GTM and WooCommerce may require some technical expertise, the benefits of tracking transactions far outweigh the effort required to set it up.