Created
December 16, 2020 09:14
-
-
Save renebakx/897f3f7405740b7b1b1fb4308b7dad8e to your computer and use it in GitHub Desktop.
Writing the iframe tag at the top of your html.html.twig file in Drupal 8/9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function tagmanager_page_top(array &$page_top) { | |
if (FALSE === \Drupal::service('router.admin_context')->isAdminRoute()) { | |
$page_top['above'] = [ | |
'#noscript' => true, | |
'#type' => 'html_tag', | |
'#tag' => 'iframe', | |
'#attributes' => [ | |
'src' => sprintf('https://www.googletagmanager.com/ns.html?id=%s',$settings->get('gtm_code')), | |
'height' => 0, | |
'width' => 0, | |
'style' => "display:none;visibility:hidden" | |
] | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment