Hi,

I am requested by our IT to add analytics code to a site.

The code includes a script declaration which should be placed at the block, and a code snippet which should be added to the section.

I added the script declaration to the using the function:
drupal_add_js('http://...', 'external');
I see it showing up on the page, so no problem here.

Unfortunately I didn't find any way to add code to the page html footer.
I found that the template does not control this section, and it is generated by modules/system/html.tpl.php. However, this file ends with:

Whereas I would have needed it to end somewhat like this:


print $html-page-footer;

And there should be a proper interface to add content to that $html-page-footer variable.

Should this be posted as a core bug?

Thanks,
-- Nir

Comments

Jaypan’s picture

See the section on configuration options, in particular, scope, here: https://www.jaypan.com/tutorial/high-performance-javascript-using-drupal...

onejam’s picture

Are you trying to add GA? just use this module: https://www.drupal.org/project/google_analytics

-----------------------------------------------------------------
We build engaging websites and intuitive designs that will benefit your business.
Duvien

narad’s picture

Unfortunately, no, it is not Google Analytics, but another company's which is mandated by our IT dept.

onejam’s picture

If that's the case, can you not just copy that template (html.tpl.php) to your theme and insert the js code snippet to the bottom before the body end tag?

-----------------------------------------------------------------
We build engaging websites and intuitive designs that will benefit your business.
Duvien

narad’s picture

In the meantime, however, we found this was a miscommunication.
They did not really intend to put the code at the HTML section but at the footer of the section, so I think I'm good.
Thanks again for the suggestions!