WooCommerce Google Tag Manager integration

WooCommerce is by far the most popular ecommerce plugin for WordPress and integrating it with Google Tag Manager and Google Analytics is easy.

Click the activation switch then click save and you are well on your way.

GTM WooCommerce integration

eCommerce events tracked with Google Analytics 4

When the integration is activated the following Google Analytics 4 events are automatically included in the dataLayer:

  • view_item_list
  • select_item
  • view_item
  • add_to_cart
  • view_cart
  • remove_from_cart
  • begin_checkout
  • add_shipping_info
  • add_payment_info
  • purchase

WooCommerce integration options

Product brand

If you wish to include the product brand in the data layer you must select the product attribute which conatins the brand value.

Brand option

By default this attribute does not exist in WooCommerce so you must first create a new brand attribute and once you have done that you can select it in the brand option.

Google Ads Remarketing

I you wish to use Google Ads Remarketing you must select your business type from one on Google’s predefined business verticals:

Google Ads Remarketing

If your product feed generator is adding a prefix to the product IDs, you can add the prefix to be included it in the Data Layer.

Tax and shipping

Whether prices should include tax or not is a matter of opinion and it’s easy to shitch between the two. It’s alsp matter of opinion whether shipping should be excluded from the revenue.

Tax and shipping

Events in checkout

Google Analytics 4 has 2 new events in the checkout and they are called add_shipping_info and add_payment_info. These events may be usefull for tracking progress in the funnel but it depends entirely on you setup.

Ideally you only want to fire these events once and the options are:

  • When the ‘Place order’ button is clicked
  • When a shipping/payment method is selected with fallback to the ‘Place order’ button.
  • Disable the event.

Ideally you should fire the event when a method is selected but what happens if the user changes the method? In this case only event will be fired but the name of method will be the first chosen method. So the usefullness of these events depends on how you checkout page is structured.

Events in checkout

View_item on variable products

A variable product like a shirt has different sizes. Each size has it’s unique product number / SKU. All product variations has a master product where the user can select size. This is a problem with the view_item event.

If you fire the event on both the master product and when a variation has been selected you will get a higher number of views than expected. If you only fire the event on the master product the will be a gap or missing link when the variation with a different product ID is addeed to the cart.

Theere is no right or wrog here but you have to choose.

View_item on variable products

Dequeue default JavaScript

If you have customized you WooCommerce store to an extend where it is no longer compatible with the JavaScript included in GTM Kit you may dequeue the JavaScript and include your own.

Dequeue default JavaScript