Built for Shopify & WooCommerce · Tracking checked every 30 minutes.

WordPress data layer: what it is and how to enable it for WooCommerce

Abir Molla
Abir MollaNov 20, 2026 · 8 min read
WordPress data layer: what it is and how to enable it for WooCommerceVideo · 11:07 · plays from YouTube

A WordPress data layer is a small JavaScript object on each page that tells Google Tag Manager what just happened: which product a visitor viewed, what they added to the cart, and what they ordered, with names, prices and the order number. WordPress and WooCommerce don't build one for Google Tag Manager on their own, so you add it with a free plugin such as GTM4WP: paste your container ID, turn on WooCommerce ecommerce tracking, and the plugin pushes GA4-style events like view_item, add_to_cart, begin_checkout and purchase on every page.

The video above shows the whole setup on a WooCommerce store, from installing the plugin to seeing a real purchase in the data layer. This post is the written version: what a data layer is, why your tracking depends on it, and the steps in the same order, updated for how the plugin and Google's tools work today.

The video is from 2022, and a few things have changed since. GTM4WP is now version 2, and the switch the video calls Track enhanced e-commerce under Integration → WooCommerce is now Track e-commerce in the plugin's WooCommerce section. The Tag Assistant Legacy extension used in the video has been merged into a single Tag Assistant extension. And Universal Analytics, where the "enhanced ecommerce" name came from, stopped processing data in July 2023, so the data layer you want today is the GA4 ecommerce format. The steps below use the current names.

What a data layer is, and why WordPress tracking needs one

Google describes the data layer as an object Google Tag Manager and the Google tag use to pass information to tags (Google, Data layer). Think of it as a note your site leaves on each page for Google Tag Manager to read.

Without it, Google Tag Manager only sees the page itself: its address, its title, the buttons people click. It doesn't know that the page is a product called "Casual Dress" with a price, or that the thank-you page belongs to order 1202. Your tags can still fire, but they fire with empty or guessed values.

With a data layer, every important moment in your store becomes an event with the details attached:

  • view_item when someone opens a product, with the product ID, name, category and price.
  • add_to_cart when they add it, with the quantity and value.
  • begin_checkout when they start checkout, with every item in the cart.
  • purchase when the order goes through, with the transaction ID, total value, currency and items.

Those are the values your GA4, Google Ads and Meta Pixel tags need. One data layer feeds all of them, so you set it up once and every tag reads the same facts. That's what the video means by tracking products "dynamically": the price and product name come from the store, not from a number you typed into a tag.

What you need

  • Admin access to WordPress, to install a plugin.
  • WooCommerce, if you want ecommerce events. GTM4WP also adds basic page data (post type, category, author, logged-in status) on any WordPress site.
  • A Google Tag Manager account with a Web container. Step 2 shows how to make one.
  • Chrome, for Google Tag Manager's Preview mode and the Tag Assistant extension.

Step 1: install GTM4WP

In your WordPress dashboard, go to Plugins → Add New and search for GTM4WP. The plugin is called "GTM4WP: A Google Tag Manager (GTM) plugin for WordPress", by Thomas Geiger. Click Install Now, then Activate.

It's free and still maintained: version 2.1.1 came out in November 2026, it's tested with the current WordPress, and it has over 700,000 active installs (GTM4WP on WordPress.org). It does two jobs. It places the Google Tag Manager container code on every page, so you don't edit your theme, and it pushes page and WooCommerce data into the data layer.

Step 2: create your Google Tag Manager container

Go to tagmanager.google.com and click Create account. Use your business name as the account name and pick your country. For the container, use your website's name and choose Web. Accept the terms.

Google Tag Manager then shows your container ID, which starts with GTM-. One account can hold several containers, one per website, so if you manage more than one site you can keep them all under the same account.

Step 3: add your container ID to WordPress

Open the GTM4WP settings. In the video that's Settings → Google Tag Manager. In the Google Tag Manager container section, add your GTM- ID and save.

Then check Container code placement. It must not be Off. That setting removes the container code and leaves only the data layer, which is meant for sites that load Google Tag Manager some other way. In the video, the container didn't load at first until the container code option was switched on, so this is the first thing to look at if Step 4 finds nothing.

If your theme or another plugin already adds Google Tag Manager, remove that copy. Two copies of the container means every tag fires twice.

Step 4: check that Google Tag Manager is loading

Install the Tag Assistant extension from the Chrome Web Store, open your website and click the extension icon. The side panel lists the Google tags it finds on the page, and you should see your GTM- container (Tag Manager Help, Tag Assistant Chrome extension).

If nothing shows up, turn off your ad blocker for your own site and reload. In the video, the container looked missing only because an ad blocker was stopping it. Your visitors with ad blockers are affected the same way, which matters later.

Step 5: look at the data layer before ecommerce tracking

In Google Tag Manager, click Preview, enter your website's address and click Connect. Your site opens in a new tab, connected to Tag Assistant.

Open any product page and look at the events on the left of the Tag Assistant panel. You'll see the standard page events and the basic WordPress data GTM4WP adds, but no product event. In the video, the product page shows no ecommerce data at all at this point. Google Tag Manager is installed, but it still doesn't know what's on the page.

Step 6: turn on WooCommerce ecommerce tracking

Back in WordPress, open the GTM4WP settings again and go to the WooCommerce section. Turn on Track e-commerce and save. It's off by default, and while it's off the plugin sends nothing from WooCommerce to the data layer (GTM4WP, GA4 for WooCommerce).

Two more options in the same section are worth knowing:

  • Customer data in data layer adds the customer's details to the purchase event, in the user_data block Google Ads enhanced conversions reads. Turn it on if you plan to use enhanced conversions or Meta's advanced matching.
  • Order statuses that trigger the purchase event decides which orders count. Processing, On hold and Completed are ticked by default.

Step 7: test a full shopping journey in Preview

Start Preview again and shop your own store like a customer. In the video, this is what showed up:

  • Product page. A view_item event. Click it, open the Data layer tab, and you'll find an ecommerce object with an items array: item ID, item name, category and price. In the video the related products also appear, under the old name "impressions". In the GA4 format they come through as a product list event instead.
  • Add to cart. An add_to_cart event with the same product details.
  • Cart. A cart event listing every item in the cart and the total value, $29.99 in the video.
  • Checkout. A begin_checkout event with the items and the value.
  • Thank-you page. A purchase event with the transaction ID (the WooCommerce order number, 1202 in the video), the total value, currency and items.

If every step shows its event with real values, your data layer works. You can now build GA4, Google Ads and Meta Pixel tags that read these values, instead of typing prices into tags by hand.

Next step: send these events to your ad platforms

A data layer on its own doesn't send anything anywhere. It's the input your tags read. From here:

Common mistakes

Track e-commerce is still off. The plugin installs Google Tag Manager without it, so everything looks fine until you open a product page in Preview and see no view_item.

Two plugins push the same data layer. GTM4WP and GTM Kit (or a WooCommerce analytics plugin) running together means doubled events and two copies of the container. Pick one.

The container is also pasted in the theme. If someone added the Google Tag Manager snippet to header.php or a header scripts plugin, the plugin adds a second copy. Remove the manual one.

Testing with an ad blocker on. Google Tag Manager won't load and you'll think the install failed. Test with it off.

Purchases missing after PayPal or another offsite payment. Some gateways don't send the buyer back to your thank-you page, so the purchase event never fires. GTM4WP's own FAQ suggests turning on auto-return in the gateway, and version 2 has a Reliable purchase tracking setting for the same problem.

A page cache serving one visitor's data to everyone. If you use a full page cache and put customer details in the data layer, a cached page can carry one visitor's details to the next. GTM4WP has a Cache-safe data layer option for this. Turn it on before you turn on customer data.

Questions people ask

Does WordPress have a data layer by default?

No. WordPress and WooCommerce don't push anything into a Google Tag Manager data layer on their own. A plugin like GTM4WP or GTM Kit adds it, or a developer writes the dataLayer.push code into the theme.

What's the difference between GTM4WP and GTM Kit?

Both are free, both add the Google Tag Manager container and a WooCommerce data layer in the GA4 ecommerce format. The variable names and settings differ a little. Use whichever your tags were built for, and never both at once.

Is the data layer the same as Google Analytics?

No. The data layer only holds the information on the page. Google Analytics, Google Ads and Meta get it only when a tag in Google Tag Manager reads the data layer and sends it on.

Do I still need the data layer if I use server-side tracking?

Yes. Server-side tracking still starts with the events on your site. The data layer is where those events and their details come from, before they're sent to a server and on to the ad platforms.

Where KiteTrack fits

A data layer gets the right facts onto the page, but the tags that read it still run in the browser, and ad blockers and browser privacy rules stop some of them. KiteTrack picks up from your WooCommerce events and runs your own tracking server on your store's subdomain. It sends your purchases and other events to Meta, Google Ads, GA4 and TikTok from that server, customer details are hashed before they leave it, and your tracking is checked every 30 minutes so a broken event becomes an alert. See how it works for WooCommerce.

Not sure whether your store's data layer and tags are sending what they should? Start with the free Tracking Check. It looks at your site in about two minutes, no signup. If you'd rather talk it through, book a call with me.

Sources

Get tracking tips by email

Short, practical fixes for Meta, Google Ads and GA4, from Abir.

You’re in. First tip lands soon.

Abir Molla
Written by Abir Molla

Tracking specialist. He builds and runs KiteTrack, and explains tracking on YouTube.

Keep reading

Let your ads see every sale.

30-day money-back guarantee · free migration · cancel any time