Home > Internet marketing and seo blog > Analytics > Add Google Analytics 4 (GA4) to a Woocommerce site with Tag Manager (GTM)

Add Google Analytics 4 (GA4) to a Woocommerce site with Tag Manager (GTM)

| |

I have Woocommerce. I would like to create a Google Tag Manager Container and add Google Analytics 4 to it to track purchases. What steps should I take?

Google Analytics 4 with Google Tag Manager in Woocommerce

To set up Google Tag Manager and add Google Analytics 4 to track purchases in your WooCommerce store, follow these steps:

  1. Set up a Google Tag Manager account:
    • Go to the Google Tag Manager website (https://tagmanager.google.com) and sign in with your Google account.
    • Click on “Create Account” and provide an account name.
    • Follow the prompts to create a new container.
  2. Install Google Tag Manager on your WooCommerce site:
    • Install and activate the “DuracellTomi’s Google Tag Manager for WordPress” plugin on your WooCommerce site.
    • Go to “Settings” in your WordPress dashboard and click on “Google Tag Manager.”
    • Enter your Google Tag Manager container ID, which you can find in the Tag Manager interface (e.g., GTM-XXXXXX).
    • Save the changes.
  3. Configure the Google Tag Manager container:
    • In the Google Tag Manager interface, open your container.
    • Click on “Tags” in the left sidebar and then “New” to create a new tag.
    • Give your tag a descriptive name, such as “Google Analytics 4 – Purchase Tracking.”
    • Click on the tag configuration area and select “Google Analytics: GA4 Configuration.”
    • Enter your Google Analytics Measurement ID, which you can obtain from your Google Analytics 4 property (e.g., G-XXXXXX).
    • Configure the triggers for your tag. For purchase tracking, you should create a trigger that fires on the “Thank You” or “Order Confirmation” page.
    • Save the tag.
  4. Publish your changes:
    • Click on “Submit” in the upper-right corner of the Google Tag Manager interface.
    • Add a descriptive version name and description for your changes.
    • Click on “Publish” to publish the changes to your container.
  5. Test the implementation:
    • Make a test purchase on your WooCommerce site and reach the “Thank You” or “Order Confirmation” page.
    • In the Google Analytics 4 interface, navigate to the “Realtime” section and check if the purchase events are being tracked.
    • Verify that the events are recorded correctly in your Google Analytics reports.

By following these steps, you should be able to set up a Google Tag Manager container and add Google Analytics 4 to track purchases in your WooCommerce store. Remember to adjust the triggers and other configurations based on your specific needs and tracking requirements.

Transaction and Transaction revenue tracking with GA4 & GTM

If I need to track transactions and transaction revenue, is there any more steps I need to take?

To track transactions and transaction revenue in Google Analytics 4 using Google Tag Manager, you’ll need to set up enhanced ecommerce tracking. Here are the additional steps:

  1. Enable Enhanced Ecommerce in Google Analytics 4:
    • Go to your Google Analytics 4 property.
    • In the left sidebar, click on “Data Streams.”
    • Click on your data stream and then click on “Configure” next to “Enhanced measurement.”
    • Enable the “Ecommerce purchases” option.
    • Save the changes.
  2. Configure Enhanced Ecommerce in Google Tag Manager:
    • In the Google Tag Manager interface, open your container.
    • Click on “Tags” in the left sidebar and find your existing Google Analytics 4 tag for purchase tracking.
    • Edit the tag and scroll down to the “Tag Configuration” section.
    • Click on the “Enable Enhanced Ecommerce Features” checkbox.
    • Save the tag.
  3. Send Enhanced Ecommerce data to Google Analytics:
    • Still in the Google Tag Manager interface, go to “Variables” in the left sidebar.
    • Click on “Configure” under the “Built-In Variables” section.
    • Enable the following variables under the “Enhanced Ecommerce” category:
      • “Transaction ID”
      • “Affiliation”
      • “Total Revenue”
      • “Tax”
      • “Shipping”
      • “Coupon Code”
      • “Product ID”
      • “Product Name”
      • “Product Price”
      • “Quantity”
    • Save the changes.
  4. Update the Google Analytics 4 tag with Enhanced Ecommerce data:
    • Go back to your Google Analytics 4 tag for purchase tracking.
    • Scroll down to the “Fields to Set” section.
    • Add the following fields and values:
      • Field Name: “send_to” Value: “G-XXXXXXXXXX” (your Google Analytics Measurement ID)
      • Field Name: “event_name” Value: “purchase”
    • In the “More Settings” section, expand the “Ecommerce” dropdown.
    • Configure the following fields:
      • “Transaction ID”: Choose the corresponding variable.
      • “Affiliation”: Choose the corresponding variable.
      • “Value”: Choose the corresponding variable for total revenue.
      • “Tax”: Choose the corresponding variable.
      • “Shipping”: Choose the corresponding variable.
      • “Coupon”: Choose the corresponding variable for coupon code.
      • “Items”: Configure the following sub-fields:
        • “Item ID”: Choose the corresponding variable for product ID.
        • “Item Name”: Choose the corresponding variable for product name.
        • “Price”: Choose the corresponding variable for product price.
        • “Quantity”: Choose the corresponding variable.
    • Save the tag.
  5. Publish your changes:
    • Click on “Submit” in the upper-right corner of the Google Tag Manager interface.
    • Add a descriptive version name and description for your changes.
    • Click on “Publish” to publish the changes to your container.
  6. Test the implementation:
    • Make a test purchase on your WooCommerce site and reach the “Thank You” or “Order Confirmation” page.
    • In the Google Analytics 4 interface, navigate to the “Conversions > Ecommerce > Purchases” section.
    • Verify that the transaction data, including revenue, tax, shipping, and coupon information, is recorded correctly.

By following these additional steps, you should be able to track transactions and transaction revenue using Google Analytics 4 with enhanced ecommerce tracking in your WooCommerce store. Remember to adjust the configuration based on your specific requirements and the data available in your WooCommerce setup.