I'm fairly new to Magento development.

How can I insert code immediately following (not before ) on the index/home only?

I'm trying to insert some JavaScript for a Google Analytics Content Experiment Code (AB test). I was told that the code must be inserted immediately following the tag. The Miscellaneous Scripts function will not work, because it inserts just before the , and after getChildHtml('head').

I'm also not sure how I'd get the home page (CMS page) to reference my custom template, should I go the more obvious route.

All insights are welcomed!


If you don't already have a local.xml in your theme folder, just plop the below code in:

<?xml version="1.0"?>
        <reference name="head">
            <action method="addItem"><type>skin_js</type><name>js/your_file.js</name></action>

Add your your_file.js to your themes js folder. Here is a good boilerplate local.xml to reference: https://gist.github.com/Maksold/3956702

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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