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.1.0. Variables and options added by 2.0.0 or 2.1.0 are marked New in 2.0.0 or New in 2.1.0. Where an older version behaves differently, its behavior is marked with a bold GTM4WP 2.0.x: or 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.
The title is reported as the visitor reads it. WordPress encodes some characters in titles, for example an ampersand as & or a typographic apostrophe as ’, and the plugin decodes them, so a post titled “Marks & Spencer” reports Marks & Spencer.
GTM4WP 2.0.x: the encoded form was reported, for example Marks & Spencer. A trigger that matches the encoded form needs the plain text after the upgrade.
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.
Term names are reported as they were typed, so a term named “Shirts & Ties” arrives with a plain ampersand. The same applies to pagePrimaryCategoryName below. When there is nothing to report, neither a term nor a custom field, the variable is left out instead of being an empty list.
GTM4WP 2.0.x: term names arrived in the encoded form WordPress stores them in, for example Shirts & Ties, and the variable was an empty list on a post with nothing to report. Update any trigger that matches the encoded form or that only tests whether the variable is present.
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 and fields that WordPress or a plugin marks as protected. It also skips fields that hold a structured value instead of plain text, because plugins store those in a packed internal format that no Google Tag Manager variable can read.
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 name only the fields you need in the key list described below, or use the gtm4wp_post_meta_in_datalayer filter to leave individual keys out.
Custom fields have their own option, called Post custom fields (meta).
New in 2.0.0. The Post custom fields – publish only these keys option takes the names of the custom fields you want in the data layer, one per line or separated by commas. When it is filled in, only the listed fields are published, so a field that a plugin, a theme or an editor adds later cannot appear on your public pages unless you add it to the list. Leave it empty to publish every field as described above. The list cannot override the rules above: a field whose name starts with an underscore, a protected field and a field left out by the filter stay out even when listed. A field name that contains a comma cannot be listed.
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.
Starting with WPML 5.0, a language code can also name a country. English (United States) is reported as en-us, and every language with regional variants follows the same pattern, while a language without a country keeps its short code, so Arabic stays ar. WPML applies this to languages added on new sites; sites that already exist keep the codes they have. GTM4WP passes the code on exactly as it receives it, so the plugin needs no update, but a trigger or variable in Google Tag Manager that compares pageLanguage to a bare code such as en does not match en-us. To match a language regardless of the country, compare only the part before the hyphen, for example with a “starts with” condition.
Output values in the default language
New in 2.1.0. On a multilingual site running WPML or Polylang, the Output values in the default language option in the Content & engagement data group reports the following variables in the default language of the site instead of the language of the current translation:
pageTitle, on single posts and pagespageCategory, parent categories includedpageAttributespagePostTerms(the term names; custom fields are reported as they are)pagePrimaryCategoryandpagePrimaryCategoryName
Use it when Google Analytics should combine the visits of one article across its translations instead of reporting each translation separately. The values replace the translated ones and no new variables are added. pageLanguage keeps reporting the language of the current page, so you can still split your reports by language. A page in the default language, a page without a translation in the default language and a site with one language report the same values as without the option.
The option is experimental and switched off by default, because it depends on the API of the multilingual plugin. To support another multilingual plugin, use the gtm4wp_master_language_post_id and gtm4wp_master_language_term_id filters. Without WPML, Polylang or a callback on one of these filters, the settings screen shows the option as disabled with the note “Needs WPML or Polylang, and neither is active.”
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.

