How to enable page/post variables?
Those variables are partly enabled by default, you will need to set the corresponding checkbox on the options page:
- Go to Settings / Google Tag Manager on your WordPress admin area
- Click on the Basic data tab
- Click on the Posts subtab
- Put a check mark into the boxes shown on that page
Enabling this will allow you to access the following Data Layer Variables on all pages:
This will include 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 but in some cases this can differ from what you see in your browser.
This will include the display name of the author of the currently visited page/post. The value will be a simple string.
This will include the internal ID of the author of the currently visited page/post. The value will be an integer number.
The pagePostDate variable will include the date of the currently visited page/post in the format set in the settings section of WordPress. The other 3 variables will only include a specific part of the same date as a number with a leading 0 for single numbers (04 for April for example)
The first variable will include 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.
The second variable will be almost the same but with a prefix to differentiate certain page types:
- tax- (for custom taxonomy pages)