Choose post and page data for the dataLayer

This guide shows you how to control which page and post fields GTM Kit adds to the data layer on every page view, and how to use them in GTM as variables.

What gets added

GTM Kit can include the following fields in the data layer for the current page or archive view:

FieldDescriptionExample value
post_typeThe WordPress post type of the current view.post, page, product
page_typeA friendly page-type label normalized by GTM Kit.post, page, product, category, cart, checkout, home, search
post_categoriesCategories of the current post or archive (array of slugs).["news","analytics"]
post_tagsTags of the current post or archive (array of slugs).["gtm","ga4"]
post_titleThe current post title."How to set up GA4"
post_idThe numeric post ID.1234
post_dateThe publish date in YYYY-MM-DD format."2026-04-29"
post_author_nameThe post author’s display name."Torben"
post_author_idThe numeric author user ID.42

Each is independently toggleable. None contain personally identifying information about the visitor; all describe the content being viewed.

When to enable each

The two most useful fields for almost every site are page_type and post_type. They let you build GTM triggers like “fire this tag only on product pages” without writing custom JS or maintaining URL pattern lists.

Categories, tags, and post_id are useful for content sites that want to slice analytics by topic or article.

Author fields are useful when you want to attribute traffic and engagement to individual writers, for example on a multi-author publication.

If you do not have a clear use for a field, leave it off. Smaller data layers are easier to debug.

Steps

1. Open General settings

Go to GTM Kit, General.

2. Find the Post Data section

Each field is a toggle. Default-on is Page Type. Other fields default to off.

3. Pick what you need and save

Saving takes effect on the next page load. Caches may need to be flushed.

Use the data in GTM

In your GTM workspace:

  1. Go to Variables, New, Data Layer Variable.
  2. Set Variable Name to anything you like, e.g. dlv - page_type.
  3. Set Data Layer Variable Name to the field key, e.g. page_type.
  4. Save.

You can now use that variable in triggers and tag parameters. A typical use:

Trigger: Custom Event page_view AND dlv - page_type equals product. → Fire your product-page remarketing tag.

Verify it worked

Open any page on your site. In DevTools console:

window.dataLayer

Find the entry where event is page_view (or your earliest data-push event) and confirm the fields you enabled are present:

{
  event: 'page_view',
  page_type: 'post',
  post_type: 'post',
  post_categories: ['news', 'analytics'],
  post_id: 1234,
  // ...
}

If a field is missing, it is either toggled off, or your theme suppresses the data-layer enqueue (rare; only happens with heavily customized themes that strip enqueued scripts).

Common issues

Fields are empty on archive pages. GTM Kit fills post_categories and post_tags based on the queried object. On a category archive, the relevant terms are derived from the archive itself. On the front page set to “your latest posts”, only page_type and post_type are meaningful; per-post fields are blank by design.

Custom post types do not show in post_type. They should. Confirm the post type is registered with public => true and that the page you are looking at is a single-CPT page, not its archive.

post_author_name is empty. Either the author has no display name set, or the page is not a singular post (archive views do not have a single author).