1

I have a google add script Which I want to integrate on the head section. How can I add the script to the head section on drupal 7 without any module and info file? Script is below:

 (function () {

        var _onload = function(){

            if (document.readyState && !/loaded|complete/.test(document.readyState)){setTimeout(_onload, 10);return}

            if (!window.__adroll_loaded){__adroll_loaded=true;setTimeout(_onload, 50);return}

            var scr = document.createElement("script");

        };
});
0

You can alter html.tpl.php and add your script in head.

Just alter html.tpl.php file from theme folder. If its not present copy it from drupal/modules/system folder.

Also you can use Js Injector module: https://www.drupal.org/project/js_injector

Hope this will help.

Thanks,

1

Add it your theme instead.

html.tpl.php would be the correct template to use.

0

Add html.tpl.php (if not in theme folder) file in theme template folder and add this script to the file.

-1

I would place this script in external js file and insert it with "drupal_add_js" function in template file.

drupal_add_js(drupal_get_path('theme', 'MYTHEME') .'/file.js', array('type' => 'external','scope' => 'header','group' => JS_THEME,'every_page' => TRUE,'weight' => -1,));

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.