WordPress page/post attributes in Google Tag Manager
Use the following data layer variables to access data about the content that is currently shown. They are available on single posts and pages and on archive pages, and they support custom post types as well.
Every variable on this page has its own option on the plugin settings screen, in the Page variables section. The post type, category list, tag list and post author name options are enabled by default. The rest are switched off until you enable them, so if a variable is missing from your data layer, check its option first.
This page describes GTM4WP 2.0.0 and newer. Variables introduced by that release are marked New in 2.0.0 and are not available in the legacy 1.x versions. Where 1.x behaved differently, the older behavior is marked with a bold GTM4WP 1.x: lead-in.
pageTitle
The title of the page, usually shown on the tab of the browser. Note that this value is generated on the server with the wp_title() function while the page is built, so in some cases it can differ from the title you see in the browser tab.
pageAttributes
A JavaScript Array containing the slugs of the tags assigned to the current post. This variable is only added on single posts and pages.
pageCategory
A JavaScript Array containing the slugs of the categories associated with the currently visited page or post. It is added on single posts and pages, and on category and custom taxonomy archive pages.
New in 2.0.0. A separate Include parent categories in the category list option adds the ancestors of each category to the same array, listed after the category itself and ordered from the immediate parent upwards. Repeated ancestors appear only once. The option requires the category list option to be enabled, and it is switched off by default, so the array is unchanged until you turn it on.
pagePostAuthor
The display name of the author of the currently visited page or post, as a string. It is also added on author archive pages.
New in 2.0.0. If PublishPress Authors is active and the post has more than one author, an additional pagePostAuthors variable holds the display names of all of them as an array, while pagePostAuthor holds the first one. A single guest author is also read from PublishPress, so the name reported is the guest author rather than the WordPress user stored on the post.
pagePostAuthorID
The internal WordPress ID of the author of the currently visited page or post. The value is an integer. It is also added on author archive pages.
New in 2.0.0. On a post with more than one PublishPress author, an additional pagePostAuthorIDs variable holds the IDs of all of them as an array. Guest authors have no WordPress user account and are reported with a negative ID.
pagePostDate and the related date variables
The Post date option adds the publication date of the current post as nine separate variables:
| Variable | Contents | Example |
|---|---|---|
pagePostDate | The full date, in the format set in the general settings of WordPress | "July 30, 2026" |
pagePostDateYear | Year, four digits | "2026" |
pagePostDateMonth | Month, two digits with a leading zero | "07" |
pagePostDateDay | Day of the month, two digits with a leading zero | "30" |
pagePostDateDayName | Name of the day of the week | "Thursday" |
pagePostDateHour | Hour on a 24 hour clock, two digits | "14" |
pagePostDateMinute | Minute, two digits | "05" |
pagePostDateIso | Full date and time in ISO 8601 format | "2026-07-30T14:05:00+02:00" |
pagePostDateUnix | Publication date as a Unix timestamp, as a number | 1785413100 |
The dates use the timezone configured for the site. The zero padded parts are strings, so pagePostDateMonth is "07" and not 7. Only pagePostDateUnix is a number.
GTM4WP 1.x: up to version 1.22.4 the data layer was encoded in a way that turned numeric looking strings into numbers, so pagePostDateMonth reached Google Tag Manager as 7 rather than "07". If one of your triggers or variables still compares a zero padded date part to a number with an “equals” condition, change that condition to the padded string. Conditions that use “greater than” or “less than” are not affected, because Google Tag Manager compares those numerically.
On date based archive pages only the matching subset of these variables is added. A year archive receives pagePostDateYear, a month archive also receives pagePostDateMonth, and day and date archives additionally receive pagePostDate and pagePostDateDay.
pagePostType
The value returned by the get_post_type() WordPress function. It can be page or post or the name of any custom post type on your site. On four kinds of pages a special value is used instead of the post type:
frontpageon the front page of your websitebloghomeon the main blog page set in the reading settings of WordPress, when that page is not the front pagesearch-resultson a search results page404-erroron a page not found error page
The search-results and 404-error values are added even when the post type option is switched off, so you can build triggers on them without enabling anything.
pagePostType2
Almost the same as pagePostType, but the post type carries a prefix that tells you which kind of page is being viewed. On a single post it reads single-post, on a category archive of posts it reads category-post, and so on. The prefixes are:
- single-
- category-
- tag-
- tax- (for custom taxonomy pages)
- author-
- year-
- month-
- day-
- date-
- time-
This variable is not added on search results pages and on 404 pages. On a static front page it comes from the single post branch, so it reads single-page while pagePostType reads frontpage.
postID
The internal WordPress ID of the current post or page, as a number. It is only added on single posts and pages.
postFormat
The post format of the current post, for example aside, gallery or video. Posts that use no particular format report standard. It is only added on single posts and pages.
GTM4WP 1.x: the variable was empty for every post that had a format, and only posts without a format reported a usable value. Review any trigger that worked around that behavior.
pagePostTerms
An object holding the taxonomy terms assigned to the current post. Every taxonomy registered for the post type becomes a key of this object, and each key holds an array of the terms assigned to the post. Note that the terms are listed by their name here, while pageCategory and pageAttributes list slugs. It is only added on single posts and pages.
pagePostTerms.meta
The custom fields (post meta) of the current post, added under the meta key of pagePostTerms. The plugin skips custom fields whose name starts with an underscore.
Please read this before you enable the option. It publishes every custom field that does not start with an underscore, together with its value, into the data layer of the public page, where any visitor can read it. That includes fields created by other plugins and themes, and Advanced Custom Fields stores its values this way, so the option can expose internal notes, IDs, prices or contact details that you did not intend to make public. Review your custom fields first, and use the gtm4wp_post_meta_in_datalayer filter to leave individual keys out.
Custom fields have their own option, called Post custom fields (meta).
GTM4WP 1.x: custom fields had no option of their own and were sent as part of the Post Terms option, whose description mentioned only taxonomies. Sites that had Post Terms enabled get Post custom fields (meta) switched on when they upgrade, so their data layer keeps carrying the same values and their Google Tag Manager setup keeps working.
pageContentWordCount
New in 2.0.0. The number of words in the content of the current post, counted after HTML tags and shortcodes are removed. It is useful to put scroll depth and engagement metrics in proportion to the length of the content. The count also handles languages that do not use the Latin alphabet, and each Chinese, Japanese or Korean character counts as one word.
pageReadingTime
New in 2.0.0. The estimated reading time of the current post in whole minutes, based on a reading speed of 200 words per minute. The value is never lower than 1. Use the gtm4wp_reading_time_wpm filter to set a different reading speed.
pageModifiedDate and the related date variables
New in 2.0.0. The Last modified date option adds the date on which the current post was last updated, using the same set of nine variables described for the post date above: pageModifiedDate, pageModifiedDateYear, pageModifiedDateMonth, pageModifiedDateDay, pageModifiedDateDayName, pageModifiedDateHour, pageModifiedDateMinute, pageModifiedDateIso and pageModifiedDateUnix.
The same rules apply as for the publication date: the zero padded parts are strings and only pageModifiedDateUnix is a number.
pageContentAgeDays
New in 2.0.0. The number of whole days that have passed since the current post was published, as a number. A post published today reports 0. Use it to separate engagement with fresh content from engagement with evergreen content.
pageCommentCount and pageCommentStatus
New in 2.0.0. The Comment count option adds two variables. pageCommentCount holds the number of comments on the current post as a number, and pageCommentStatus holds open or closed, depending on whether the post still accepts new comments.
pageTemplate
New in 2.0.0. The template file assigned to the current post or page, for example template-landing.php. Posts that use the default template of the theme report default. Use it to compare visitor behavior across page layouts.
pageHasFeaturedImage
New in 2.0.0. A boolean value that tells whether the current post has a featured image set.
pageParentID and pageDepth
New in 2.0.0. The Page hierarchy option adds two variables. pageParentID holds the ID of the parent post and is 0 when the post has no parent. pageDepth holds how deep the post sits in the hierarchy, counted as its number of ancestors, so a top level page reports 0.
pagePostSticky
New in 2.0.0. A boolean value that tells whether the current post is marked as sticky.
pagePrimaryCategory and pagePrimaryCategoryName
New in 2.0.0. The primary category of the current post, as chosen in Yoast SEO or Rank Math. pagePrimaryCategory holds its slug and pagePrimaryCategoryName holds its name. If neither plugin has a primary category stored for the post, the first category assigned to it is used. Use the gtm4wp_primary_category_term_id filter to report a different term, for example when you use another SEO plugin or a custom taxonomy.
These two variables give you a single content grouping dimension, which is easier to work with in reports than the full category array in pageCategory.
pageLanguage
New in 2.0.0. The language code of the current page. The plugin reads it from WPML or Polylang when either of them is active, and falls back to the locale of the site. Use the gtm4wp_page_language filter to report a different value, for example when your site runs on another multilingual plugin.
Variables that are missing from the data layer
When the plugin cannot work out a value, for example on a page whose template does not set up a post object, the affected variables are left out of the data layer instead of being added with an empty value. Build your Google Tag Manager triggers so that they cope with a variable that is not present, rather than expecting an empty string or a zero.
GTM4WP 1.x: the variables were added with an empty value instead of being left out.
Related pages
The number of posts shown on an archive page and the total number of posts in a taxonomy are described on the page and post listings page. See also site search, user and visitor data and multisite information.
