Archived topic
Which hook to use for inserting script right after
2 replies · Started by Bahador on April 6, 2017
I need to add Google's Tag Manager script immediately after opening <body>. Which hook field should I use?
Hi there,
wp_head should work.
Let me know.
Here's from their instructions:
Copy and paste the code snippets into your website as instructed. The
<script>portion of the JavaScript snippet will be placed in the of your web page's HTML output, and the<noscript>section should appear immediately after the opening<body>element.
So the <script> portion goes into the wp_head hook, and the <noscript> section should go into the Before Header hook.
Hope this helps :)