1

We use Google Analytics on each of our sites for our own reporting. We have implemented GA using the Google Analytics module, and everything works as expected.

However, I'm also part of a large organization that wants to start collecting analytics (using GA) on all of its sites. I've been given a .js file that I just need to add to the head of every page.

Should this be added in each site's theme or added to the GA module somehow?

Thanks for taking the time to look...

3

When I have been in this situation, I use the GA module, look at the JS file that the organization give me, and then update the Code snippet (before) and or Code snippet (after) under the Advanced Settings => Custom Javascript code tab on admin/config/system/googleanalytics as needed.

0

If you already have the physical .js file I recommend you to add the .js file into your Drupal custom theme folder.

  • add js file under drupal/sites/all/themes/custom_theme/js
  • edit theme info file custom_theme.info and add this line to it

    scripts[] = js/your_javascript_file.js

0

Thank you @MDP and @Aboodred1 for your answers, both of which would solve the problem. However, I think I've discovered a way that is more appropriate for my situation. I'm adding it here for posterity.

We're going to create a small module that can be deployed to each of our sites. Has the benefit of being version controlled, can be turned on and off, and we don't have to maintain multiple copies of the js file. Plus, I don't have to dissect the JS file and possibly introduce errors accidentally. Thanks again.

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.