Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The error:
Notice: Undefined variable: data_layer in _google_tag_classes_save() (line 239 of /svn/trunk/htdocs/sites/all/modules/google_tag/includes/admin.inc).
The code that is causing the problem:
/**
* Stores data layer classes based on current settings.
*/
function _google_tag_classes_save($realm_name = '', $realm_key = '') {
if (module_exists('datalayer') && $data_layer == 'dataLayer') {
// Save classes for data layer.
// @todo How to or can we set the name of the data layer?
// This is an open issue on datalayer project; after it is implemented in
// datalayer then remove second condition on if block.
_google_tag_data_layer_snippet($classes);
if ($realm_name) {
variable_realm_set($realm_name, $realm_key, 'google_tag_data_layer_classes', $classes);
}
else {
variable_set('google_tag_data_layer_classes', $classes);
}
}
}
The $data_layer variable is not defined in the function scope. Not sure what the fix is here.
Comments
Comment #2
slydevil CreditAttribution: slydevil commentedComment #3
solotandem CreditAttribution: solotandem commentedSee #2875358: Undefined $data_layer variable in _google_tag_classes_save().
Fixed in dev release. [if you disagree, then reopen or create another issue.]