Hi,

I was not able to figure out myself where I can add Scripts to my Drupalsite. For example Google Analytics Tracker and/ Or BotTrap-Scripts. The last one for example must be the first piece of code before the Drupal code starts. In which file would I add such scripts/ codes? I tried various,...but it caused only trouble. Which would be the general file? Although I have a customized design I hope you can help me, at least give me a clue.

Thanks. Jab

Comments

stevenstewie’s picture

:) Can really nobody tell me in what file I can edit the first line of code on a Drupal website?

asdfghjklñ’s picture

You only waited seven hours. I think this forum moves much, much slower than that.

However, I'm a complete noob too, and I'm interested in themeing questions at the moment. Drupal seems to me like a complete dog to theme - it is completely different to anything I've seen before, and relies so heavily on php and css code actually in the theme itself. I come from e107 and they've got the best themeing I've ever seen. You make your layout in tables or divs, and add things like {menu=1} into the places where you want stuff to appear. Soooo easy and flexible.

What have you tried so far to get your js included?

In the page.tpl.php file there is usually a section containing:

< ?php print drupal_get_js('header', $js); ? >

There is a folder called 'misc' with some javascript files in it.
I wonder if you put your js files in there, whether Drupal will load them into the head?

The other thing I can think of is putting the js in your theme folder and putting this into the head section of the page.tpl.php:

< script type="text/javascript" src="/themes/themename/script.js" >

marcvangend’s picture

What do you mean by "the first line of code"? You don't want to edit the doctype declaration, do you?
Well, even if you did, the place to look for it is in 'page.tpl.php' in the folder of your theme. If you need Google Analytics (or another piece of code) on every single page, you can add it there.

Antifreeze,
Check out the drupal_add_js function in the drupal api reference (http://api.drupal.org/api/function/drupal_add_js/5) and search the forum for drupal_add_js or drupal_get_js.

stevenstewie’s picture

Great,...that`s exactly what I needed. I want to add analytics.
Thank you very much.