I have a recently found a couple of tags that recommend install the code directly beneath the opening tag. This is the recommended install location for LiveEngage Tag and Google Tagmanager.

You can add code easily before the closing tag under General > Design > Footer > Miscellaneous HTML

How can we achieve the same functionality immediately after the opening tag?

3 Answers 3


I would recommend the following approach for adding third party scripts in Magento:

1) Open your theme layout update file(preferably local.xml)

2) Add the following xml code:

    <reference name="after_body_start">
        <block type="core/template" name="after_body_start_script" template="page/html/scripts/after_body_start.phtml" />
    <reference name="before_body_end">
        <block type="core/template" name="before_body_end_script" template="page/html/scripts/before_body_end.phtml" />

3) Now you can add the relevant scripts to the the files page/html/scripts/after_body_start.phtml

  • 1
    I tried this to include a custom template file in adminhtml after_body_start but it is not working. Do I need to echo getChildHtml('after_body_start') somewhere? Mar 1, 2017 at 9:22
General > Design > Footer > Miscellaneous HTML

This setting will add code just before closing body tag.

If you want to add code just after body tag you will need to us XML reference after_body_start

<block type="core/text_list" name="after_body_start" as="after_body_start" translate="label">
        <label>Page Top</label>

You can take reference of after_body_start and can able to add your code.

<reference name="after_body_start">
// your block and template goes here..

I recommend using the following path once you have logged into your Magento account to install your tag before the closing body tag!

System > Configuration > Design >HTML Head > Footer > Miscellaneous Footer

Here is where you can enter your tag before the closing body tag!

  • 1
    That's what OP already wrote. The actual question was how to add code before the opening body tag. May 17, 2016 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.