WordPress page/post attributes in Google Tag Manager
Use the following data layer variables to access data about the currently shown content in single and archive pages and posts supporting custom post types as well. With the following data layer variables you can access page and post attributes in Google Tag Manager.
pageTitle
The title of the page, usually shown on the tab of the browser. Note, that this value will be generated on the server during page generation using the wp_title() function. This is usually the value of the page title in the browser tab but in some cases this can differ from what you see as tab title.
pageAttributes
A JavaScript Array with the tags associated with the currently visited page/post.
pageCategory
A JavaScript Array with the categories associated with the currently visited page/post.
pagePostAuthor
The display name of the author of the currently visited page/post. The type of the value will be a simple String.
pagePostAuthorID
The internal ID of the author of the currently visited page/post. The value will be an Integer number.
pagePostDate, pagePostDateYear, pagePostDateMonth, pagePostDateDay
The pagePostDate variable will include the date of the currently visited page/post in the format set in the settings section of WordPress. The remaining 3 variables will only include a specific part of the same date as a number with a leading 0 for single numbers (04=April for example)
pagePostType
The value returned by the get_post_type() WordPress function. Can be page or post or the name of any custom post type on your site. The special value frontpage
will be set when the user is on the frontpage of your website and bloghome
if the user is on the main blog page set in the settings section of WordPress.
pagePostType2
It is almost the same as pagePostType, but with a prefix to differentiate certain page types:
- single-
- category-
- tag-
- tax- (for custom taxonomy pages)
- author-
- year-
- month-
- day-
- date-
- time-