• Resolved Haneef

    (@haneef95)


    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

    (@diana_burduja)

    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.

    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 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 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.
Viewing 1 replies (of 1 total)

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