https://www.drupal.org/node/264927#comment-9123705

Google Analytics 6.x-4.0 creates JavaScript for insertion in a preprocess function which works if you are using a templated theme but not with one like the core theme, Chameleon.

My workaround was to add the following at the very start of the function chameleon_page() in the chameleon.theme file. I also copied the entire theme to sites/all/themes to prevent the change being overwritten by core updates.

  $dummy = null;
  googleanalytics_add_js($dummy, $dummy);

There may well be better ways to solve this problem.
I also observe that Google Analytics 6.x-4.0 inserts JavaScript in to the head, not the foot, of the page so I wonder if the print $closure tip is out of date.

TODO: Identify the root cause and fix if broken.

Comments

hass’s picture

hass’s picture

This seems to be enough, but is not the way how it should work:

$output .= drupal_get_css();
googleanalytics_add_js(); // Execute theme preprocess functions manually.
$output .= drupal_get_js();

  • hass committed 14ee2c0 on 6.x-4.x
    Issue #2335391 by hass: Add Chameleon theme fails to add JS code to page...
hass’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.