diff --git a/google_tag_manager.admin.inc b/google_tag_manager.admin.inc
index 6eb55ee..0eefe52 100644
--- a/google_tag_manager.admin.inc
+++ b/google_tag_manager.admin.inc
@@ -25,6 +25,46 @@ function google_tag_manager_admin_settings_form($form_state) {
     '#type' => 'textfield',
   );
 
+  // Custom variables.
+  $form['google_tag_manager_custom_vars'] = array(
+    '#collapsed' => TRUE,
+    '#collapsible' => TRUE,
+    '#theme' => 'google_tag_manager_admin_custom_vars_table',
+    '#title' => t('Custom variables'),
+    '#tree' => TRUE,
+    '#type' => 'fieldset',
+  );
+
+  $custom_vars = variable_get('google_tag_manager_custom_vars', array());
+
+  for ($i = 0; $i < count($custom_vars) + 1; $i++) {
+    $form['google_tag_manager_custom_vars'][$i]['name'] = array(
+      '#default_value' => !empty($custom_vars[$i]['name']) ? $custom_vars[$i]['name'] : '',
+      '#description' => t('The custom variable name.'),
+      '#maxlength' => 255,
+      '#size' => 20,
+      '#title' => t('Custom variable name #@slot', array('@slot' => $i)),
+      '#title_display' => 'invisible',
+      '#type' => 'textfield',
+      '#token_types' => array('node'),
+    );
+    $form['google_tag_manager_custom_vars'][$i]['value'] = array(
+      '#default_value' => !empty($custom_vars[$i]['value']) ? $custom_vars[$i]['value'] : '',
+      '#description' => t('The custom variable value.'),
+      '#maxlength' => 255,
+      '#title' => t('Custom variable value #@slot', array('@slot' => $i)),
+      '#title_display' => 'invisible',
+      '#type' => 'textfield',
+      '#token_types' => array('node'),
+    );
+  }
+
+  $form['google_tag_manager_custom_vars']['token_tree'] = array(
+    '#theme' => 'token_tree',
+    '#token_types' => array('node'),
+    '#dialog' => TRUE,
+  );
+
   return system_settings_form($form);
 }
 
@@ -39,4 +79,14 @@ function google_tag_manager_admin_settings_form_validate($form, &$form_state) {
     form_set_error('google_tag_manager_account',
                    t('A valid Google Tag Manager container ID is case sensitive and is formatted like GTM-XXXX'));
   }
+
+  foreach ($form_state['values']['google_tag_manager_custom_vars'] as $i => $custom_var) {
+    $custom_var['name'] = trim($custom_var['name']);
+    $custom_var['value'] = trim($custom_var['value']);
+    // Unset empty pairs from the array.
+    if (empty($custom_var['name']) && empty($custom_var['value'])) {
+      unset($form_state['values']['google_tag_manager_custom_vars'][$i]);
+      continue;
+    }
+  }
 }
diff --git a/google_tag_manager.module b/google_tag_manager.module
index 2d97e17..42f38f9 100644
--- a/google_tag_manager.module
+++ b/google_tag_manager.module
@@ -70,6 +70,17 @@ function google_tag_manager_page_alter(&$page) {
 }
 
 /**
+ * Implements hook_theme().
+ */
+function google_tag_manager_theme() {
+  return array(
+    'google_tag_manager_admin_custom_vars_table' => array(
+      'render element' => 'form',
+    ),
+  );
+}
+
+/**
  * Outputs the Google Tag Manager JavaScript snippet.
  * @param string $container_id
  * GTM container identifier
@@ -82,6 +93,14 @@ function _google_tag_manager_snippet($container_id = '', $custom_name = 'dataLay
   }
 
   $snippet = <<<EOL
+  // Load and insert each custom variable.
+  $json = array();
+  $custom_vars = variable_get('google_tag_manager_custom_vars', array());
+  foreach($custom_vars as $var) {
+    $json[token_replace($var['name'])] = token_replace($var['value']);
+  }
+  $snippet = '<script>' . $customName . ' = ['  . drupal_json_encode($json) .'] </script>';
+
 <!-- Google Tag Manager -->
 <noscript><iframe src="//www.googletagmanager.com/ns.html?id=$container_id"
 height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
