Question to add code to Drupal site

Events happening in the community are now at Drupal community events on www.drupal.org.
tanyagm's picture

Hi everyone,
This is going to make all the experts in the group wince... it's so easy you likely won't put finger to keyboard to answer...
but it's worth a shot.

Being without a developer presently, I do not know the simplest way I can add a third-party Javascript to my Drupal site.

Does anyone have the patience to give me a 1-2-3 walk through?

I'm trying to use a trial version of KISSMEtrics on my site to analyze conversion rate ... but need to do this step before moving forward.

Thank you all for your consideration.

Tanya
GOTRIbal.com

Comments

Theme .info

druroot's picture

The easiest way is probably to add a line to the .info file of your theme that points to a javascript file. The example below will add the jquery scrollto package from the js directory of my theme.

scripts[] = "js/jquery.scrollTo-min.js"

you can also use a drupal_add_js() call somewhere in your template.php or, even better, if you have a module that you're putting customizations in, call drupal_add_js() from there.

adding code

tanyagm's picture

Thank you for your response. Unfortunately, I've never actually played in, visited or otherwise roamed around the code, so your advice is falling on ridiculously inept grey matter.

When I meant, Step-by-Step, i wasn't kidding.

thank you for trying. ;-)

probably the easiest

kscheirer's picture

no-code way to do this would be to

  1. Create a new block
  2. paste your javascript into the block body
  3. make sure the input format is set to "full html" - you'll need to be the admin user to see this option
  4. then assign the block to "show on all pages"
  5. assign the block to a region of the page (header, content, footer, etc)

Visually, there should be no impact since the block has no html in it. But if you view source, your javascript should be there. Some scripts are finicky about where they are loaded, and I know nothing about KISSMEtrics, but hopefully thats a start!

San Diego DUG

Group categories

Event Classifications

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: