Index: sites/all/modules/contrib/google_tag/google_tag.module
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- sites/all/modules/contrib/google_tag/google_tag.module	(revision 87bf45f7ebc544d0d81faafa76c03fbfba0a5c0f)
+++ sites/all/modules/contrib/google_tag/google_tag.module	(revision )
@@ -164,14 +164,14 @@
   //     - google_tag_page_process(): callback set here
 
   $base_path = 'public:/';
-  $include_classes = variable_get('google_tag_include_classes', 0);
+  $include_classes = _google_tag_variable_clean('google_tag_include_classes', 0);
 
   list($realm_name, $realm_key) = google_tag_realm_values();
   $types = $include_classes ? array('data_layer', 'script') : array('script');
 
-  $data_layer = variable_get('google_tag_data_layer', 'dataLayer');
+  $data_layer = _google_tag_variable_clean('google_tag_data_layer', 'dataLayer');
   if ($include_classes && module_exists('datalayer') && $data_layer == 'dataLayer') {
-    $classes = variable_get('google_tag_data_layer_classes', array());
+    $classes = _google_tag_variable_clean('google_tag_data_layer_classes', array());
     if ($classes) {
       // Add data_layer using dataLayer module.
       datalayer_add($classes);
@@ -180,7 +180,7 @@
   }
 
   // Add data_layer and script snippets to head (by default).
-  $include_script_as_file = variable_get('google_tag_include_file', 1);
+  $include_script_as_file = _google_tag_variable_clean('google_tag_include_file', 1);
   if ($include_script_as_file) {
     foreach ($types as $type) {
       // A stream wrapper may be passed as $data to drupal_add_js($data) because
@@ -218,7 +218,6 @@
       '#weight' => -10,
     );
   }
-
 }
 
 /**
@@ -254,13 +253,20 @@
     drupal_alter('google_tag_realm', $realm_values);
     $realm_name = $realm_values['name'];
     $realm_key = $realm_values['key'];
+  }
 
-    $debug = variable_get('google_tag_debug_output', 0);
-    $debug ? drupal_set_message(t('realm:key = @realm:@key', array('@realm' => $realm_name, '@key' => $realm_key))) : '';
+  // Allow other modules to alter the realm name and key.
+  $realm_values = array('name' => $realm_name, 'key' => $realm_key);
+  drupal_alter('google_tag_realm', $realm_values);
+  $realm_name = $realm_values['name'];
+  $realm_key = $realm_values['key'];
+
+  $debug = _google_tag_variable_clean('google_tag_debug_output', 0);
+  $debug ? drupal_set_message(t('realm:key = @realm:@key', array('@realm' => $realm_name, '@key' => $realm_key))) : '';
 
-    $realm_name .= $realm_name ? '/' : '';
-    $realm_key .= $realm_key ? '.' : '';
-  }
+  $realm_name .= $realm_name ? '/' : '';
+  $realm_key .= $realm_key ? '.' : '';
+
   return array($realm_name, $realm_key);
 }
 
@@ -271,7 +277,7 @@
  *   TRUE if the conditions are met; FALSE otherwise.
  */
 function google_tag_insert_snippet() {
-  $id = variable_get('google_tag_container_id', '');
+  $id = _google_tag_variable_clean('google_tag_container_id', '');
 
   if (empty($id)) {
     // No container ID.
@@ -284,7 +290,7 @@
   }
   // Allow other modules to alter the insertion criteria.
   drupal_alter('google_tag_insert', $satisfied);
-  $debug = variable_get('google_tag_debug_output', 0);
+  $debug = _google_tag_variable_clean('google_tag_debug_output', 0);
   $debug ? drupal_set_message(t('after alter @satisfied', array('@satisfied' => $satisfied))) : '';
   return $satisfied;
 }
@@ -299,9 +305,9 @@
   static $satisfied;
 
   if (!isset($satisfied)) {
-    $debug = variable_get('google_tag_debug_output', 0);
-    $toggle = variable_get('google_tag_status_toggle', GOOGLE_TAG_EXCLUDE_LISTED);
-    $statuses = variable_get('google_tag_status_list', GOOGLE_TAG_STATUSES);
+    $debug = _google_tag_variable_clean('google_tag_debug_output', 0);
+    $toggle = _google_tag_variable_clean('google_tag_status_toggle', GOOGLE_TAG_EXCLUDE_LISTED);
+    $statuses = _google_tag_variable_clean('google_tag_status_list', GOOGLE_TAG_STATUSES);
 
     if (empty($statuses)) {
       $satisfied = ($toggle == GOOGLE_TAG_EXCLUDE_LISTED);
@@ -328,9 +334,9 @@
   static $satisfied;
 
   if (!isset($satisfied)) {
-    $debug = variable_get('google_tag_debug_output', 0);
-    $toggle = variable_get('google_tag_path_toggle', GOOGLE_TAG_EXCLUDE_LISTED);
-    $paths = variable_get('google_tag_path_list', GOOGLE_TAG_PATHS);
+    $debug = _google_tag_variable_clean('google_tag_debug_output', 0);
+    $toggle = _google_tag_variable_clean('google_tag_path_toggle', GOOGLE_TAG_EXCLUDE_LISTED);
+    $paths = _google_tag_variable_clean('google_tag_path_list', GOOGLE_TAG_PATHS);
 
     if (empty($paths)) {
       $satisfied = ($toggle == GOOGLE_TAG_EXCLUDE_LISTED);
@@ -363,9 +369,9 @@
   static $satisfied;
 
   if (!isset($satisfied)) {
-    $debug = variable_get('google_tag_debug_output', 0);
-    $toggle = variable_get('google_tag_role_toggle', GOOGLE_TAG_EXCLUDE_LISTED);
-    $roles = variable_get('google_tag_role_list', array());
+    $debug = _google_tag_variable_clean('google_tag_debug_output', 0);
+    $toggle = _google_tag_variable_clean('google_tag_role_toggle', GOOGLE_TAG_EXCLUDE_LISTED);
+    $roles = _google_tag_variable_clean('google_tag_role_list', array());
     $roles = array_filter($roles);
 
     if (empty($roles)) {
@@ -381,3 +387,32 @@
   }
   return $satisfied;
 }
+
+/**
+ * Returns a cleansed variable.
+ *
+ * @param string $variable
+ *   The variable name.
+ * @param string $variable
+ *   The default value for the variable.
+ *
+ * @return string
+ *   The cleansed variable.
+ */
+function _google_tag_variable_clean($variable, $default = '') {
+  $variable_value = _google_tag_variable_get($variable, $default);
+  return trim(drupal_json_encode($variable_value), '"');
+}
+
+/**
+ * Function to alter google tag variables on domain level.
+ *
+ * @param $variable
+ * @param string $default
+ * @return null
+ */
+function _google_tag_variable_get($variable, $default = '') {
+  $variable_value = variable_get($variable, $default);
+  drupal_alter('google_tag_variable', $variable_value, $variable, $default);
+  return $variable_value;
+}
\ No newline at end of file
Index: sites/all/modules/contrib/google_tag/includes/snippet.inc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- sites/all/modules/contrib/google_tag/includes/snippet.inc	(revision 87bf45f7ebc544d0d81faafa76c03fbfba0a5c0f)
+++ sites/all/modules/contrib/google_tag/includes/snippet.inc	(revision )
@@ -36,7 +36,7 @@
   $container_id = _google_tag_variable_clean('google_tag_container_id');
   $data_layer = _google_tag_variable_clean('google_tag_data_layer', 'dataLayer');
   $query = _google_tag_environment_query();
-  $compact = variable_get('google_tag_compact_snippet', 1);
+  $compact = _google_tag_variable_clean('google_tag_compact_snippet', 1);
 
   // Build script snippet.
   $script = <<<EOS
@@ -77,7 +77,7 @@
   // Gather data.
   $container_id = _google_tag_variable_clean('google_tag_container_id');
   $query = _google_tag_environment_query();
-  $compact = variable_get('google_tag_compact_snippet', 1);
+  $compact = _google_tag_variable_clean('google_tag_compact_snippet', 1);
 
   // Build noscript snippet.
   $noscript = <<<EOS
@@ -105,10 +105,10 @@
  */
 function _google_tag_data_layer_snippet(&$classes = array()) {
   // Gather data.
-  $data_layer = variable_get('google_tag_data_layer', 'dataLayer');
+  $data_layer = _google_tag_variable_clean('google_tag_data_layer', 'dataLayer');
   $data_layer = trim(drupal_json_encode($data_layer), '"');
-  $whitelist = variable_get('google_tag_whitelist_classes', GOOGLE_TAG_WHITELIST_CLASSES);
-  $blacklist = variable_get('google_tag_blacklist_classes', GOOGLE_TAG_BLACKLIST_CLASSES);
+  $whitelist = _google_tag_variable_clean('google_tag_whitelist_classes', GOOGLE_TAG_WHITELIST_CLASSES);
+  $blacklist = _google_tag_variable_clean('google_tag_blacklist_classes', GOOGLE_TAG_BLACKLIST_CLASSES);
 
   $classes = array();
   $names = array('whitelist', 'blacklist');
@@ -132,7 +132,7 @@
  *   The query string.
  */
 function _google_tag_environment_query() {
-  if (!variable_get('google_tag_include_environment', 0)) {
+  if (!_google_tag_variable_clean('google_tag_include_environment', 0)) {
     return '';
   }
 
@@ -143,18 +143,3 @@
   // Build query string.
   return "&gtm_auth=$environment_token&gtm_preview=$environment_id&gtm_cookies_win=x";
 }
-
-/**
- * Returns a cleansed variable.
- *
- * @param string $variable
- *   The variable name.
- * @param string $variable
- *   The default value for the variable.
- *
- * @return string
- *   The cleansed variable.
- */
-function _google_tag_variable_clean($variable, $default = '') {
-  return trim(drupal_json_encode(variable_get($variable, $default)), '"');
-}
Index: sites/all/modules/contrib/google_tag/google_tag.install
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- sites/all/modules/contrib/google_tag/google_tag.install	(revision 87bf45f7ebc544d0d81faafa76c03fbfba0a5c0f)
+++ sites/all/modules/contrib/google_tag/google_tag.install	(revision )
@@ -55,7 +55,7 @@
   $t = get_t();
   $requirements = array();
   if ($phase == 'runtime') {
-    if (!preg_match('/^GTM-\w{4,}$/', variable_get('google_tag_container_id', ''))) {
+    if (!preg_match('/^GTM-\w{4,}$/', _google_tag_variable_clean('google_tag_container_id', ''))) {
       // Google Tag Manager container ID has not been set.
       $args = array('@path' => '/admin/config/system/google_tag');
       $description = $t('Configure this integration module on its <a href="@path">settings page</a>.', $args);
@@ -113,7 +113,7 @@
  */
 function google_tag_update_7101(&$sandbox) {
   $roles = user_roles();
-  $old_values = variable_get('google_tag_role_list', array());
+  $old_values = _google_tag_variable_clean('google_tag_role_list', array());
   $new_values = array();
   foreach ($old_values as $rid => $old_value) {
     $role_name = $roles[$rid];
Index: sites/all/modules/contrib/google_tag/includes/admin.inc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- sites/all/modules/contrib/google_tag/includes/admin.inc	(revision 87bf45f7ebc544d0d81faafa76c03fbfba0a5c0f)
+++ sites/all/modules/contrib/google_tag/includes/admin.inc	(revision )
@@ -101,7 +101,7 @@
       }
     }
     $element['#type'] = google_tag_form_element_type($element['#type']);
-    $element['#default_value'] = variable_get($name, $variable['default']);
+    $element['#default_value'] = _google_tag_variable_clean($name, $variable['default']);
     $element += isset($variable['element']) ? $variable['element'] : array();
     $elements[$name] = $element;
   }
