I need to insert the Google Tag Manager snippet code into each page just after the opening
<body> tag. This is fine, except I would also like the user to specify the account number in an admin form, so what is put in this form will be output in the snippet.
In the snippet, the account number is required twice:
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=<ACCOUNT NO HERE>" ... (window,document,'script','dataLayer','<ACCOUNT NO HERE>');</script>
Setting up the admin form and storing and retrieving it by
variable_get() is no problem, but what's the best way to insert it into the template?
My thought is to use
hook_preprocess_page(), but I'm not sure if this is the right hook to use, and if it is - what part of the array I would need to change to get this to appear? Or would a better way would be to make a variable available to the
tpl.php file and insert it there? In which case, how would this be achieved? Thanks!