Title: Insert code after a specific tag
Last modified: February 3, 2018

---

# Insert code after a specific tag

 *  Resolved [Haneef](https://wordpress.org/support/users/haneef95/)
 * (@haneef95)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/insert-code-after-a-specific-tag/)
 * Hi,
    Can I specify the code insertion before/after a specific tag using XPath?
   llike
 * `/html/body`
 * Basically, I need to Install this Google Tag Manager script after the <body> 
   tag:
 *     ```
       <!-- Google Tag Manager (noscript) -->
       <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
       height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
       <!-- End Google Tag Manager (noscript) -->
       ```
   
 * Thanks,

Viewing 1 replies (of 1 total)

 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/insert-code-after-a-specific-tag/#post-9935849)
 * Hi,
 * WordPress allows you to insert code only in specific places. Those places are
   called hooks. Here you can find the [list of available hooks](https://codex.wordpress.org/Plugin_API/Hooks_2.0.x).
 * Unfortunately there is no hook immediately after the <body> tag.
 * But you can simply insert the Google Tag Manager in the header. I know that [the Developer Guide](https://developers.google.com/tag-manager/devguide)
   recommends to have it after the <body> tag, but it works also in the header.
 * For example, in the FAQ of the [DuracellTomi’s Google Tag Manager for WordPress](https://wordpress.org/plugins/duracelltomi-google-tag-manager/)
   plugin you’ll find the question “Why can not this plugin insert the container
   snippet after the opening body tag automatically?”. The answer given there is
   similar.
    -  This reply was modified 8 years, 4 months ago by [SilkyPress](https://wordpress.org/support/users/diana_burduja/).

Viewing 1 replies (of 1 total)

The topic ‘Insert code after a specific tag’ is closed to new replies.

 * ![](https://ps.w.org/custom-css-js/assets/icon-128x128.png?rev=1303730)
 * [Simple Custom CSS and JS](https://wordpress.org/plugins/custom-css-js/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-css-js/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-css-js/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-css-js/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-css-js/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-css-js/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * Last activity: [8 years, 4 months ago](https://wordpress.org/support/topic/insert-code-after-a-specific-tag/#post-9935849)
 * Status: resolved