I have Google tag manager drupal module, it is using hook_page_alter to include google tag manager snippet but in print pages hook_page_alter in not executing.
Here is the function code.

/**
* Implements hook_page_alter().
*
* Adds a post_render callback and loads the include file.
*
* @see drupal_render_page()
*/
function google_tag_page_alter(&$page) {
if (!google_tag_insert_snippet()) {
return;
}

// Call sequence:
// - drupal_render_page()
// - hook_page_alter()
// - drupal_render()
// - drupal_render()
// - callbacks in $elements['#theme_wrappers']
// - hook_preprocess_html(): 'html' is the wrapper for page
// - templates may add tags after body tag
// - callbacks in $elements['#post_render']
// - google_tag_page_process(): callback set here

// Add callback routine.
$page['#post_render'][] = 'google_tag_page_process';
// Load include file.
module_load_include('inc', 'google_tag', 'includes/snippet');
}

Comments

manjunathdv16 created an issue. See original summary.

dvmanjunath’s picture

Status: Active » Closed (works as designed)