# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: contributions/modules/google_analytics/googleanalytics.admin.inc
--- contributions/modules/google_analytics/googleanalytics.admin.inc Base (1.4.2.14)
+++ contributions/modules/google_analytics/googleanalytics.admin.inc Locally Modified (Based On 1.4.2.14)
@@ -237,6 +237,51 @@
     '#description' => t("Code in this textarea will be added <strong>after</strong> pageTracker._trackPageview(). This is useful if you'd like to track a site in two accounts.")
   );
 
+  $form['advanced']['custom_var'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Custom Variables'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#description' => t('You can add Google Analytics <a href="@custom_var">Custom Variables</a> here. These will be added to every page that Google Analytics appears on.', array('@custom_var' => 'http://code.google.com/intl/zh-TW/apis/analytics/docs/tracking/gaTrackingCustomVariables.html'))
+  );
+  if (module_exists('token')) {
+    $form['advanced']['custom_var']['token_help'] = array(
+      '#title' => t('Replacement patterns'),
+      '#type' => 'fieldset',
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+      );
+
+    $form['advanced']['custom_var']['token_help']['help'] = array(
+      '#value' => theme('token_help', 'node'),
+      );
+  }
+  for ($i=1;$i<6;$i++) {
+    $form['advanced']['custom_var']['googleanalytics_custom_var_'. $i .'_name'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Name of index %index', array('%index' => $i)),
+      '#default_value' => variable_get('googleanalytics_custom_var_'. $i .'_name', ''),
+      '#description' => t('The name for the custom variable for index @i.', array('@i' => $i)),
+    );
+    $form['advanced']['custom_var']['googleanalytics_custom_var_'. $i .'_value'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Value of %index', array('%index' => $i)),
+      '#default_value' => variable_get('googleanalytics_custom_var_'. $i .'_value', ''),
+      '#description' => t('The value for the custom variable for index @i.', array('@i' => $i)),
+    );
+    $form['advanced']['custom_var']['googleanalytics_custom_var_'. $i .'_scope'] = array(
+      '#type' => 'select',
+      '#title' => t('Scope of %index', array('%index' => $i)),
+      '#default_value' => variable_get('googleanalytics_custom_var_'. $i .'_scope', 3),
+      '#options' => array(
+        3 => "page", 
+        2 => "session",
+        1 => "visitor",
+      ),
+      '#description' => t('The scope for the custom variable for this var.')
+    );
+  }
+  
   $form['advanced']['googleanalytics_js_scope'] = array(
     '#type' => 'select',
     '#title' => t('JavaScript scope'),
Index: contributions/modules/google_analytics/googleanalytics.install
--- contributions/modules/google_analytics/googleanalytics.install Base (1.6.2.12)
+++ contributions/modules/google_analytics/googleanalytics.install Locally Modified (Based On 1.6.2.12)
@@ -39,7 +39,12 @@
   variable_del('googleanalytics_visibility');
   variable_del('googleanalytics_pages');
   variable_del('googleanalytics_translation_set');
+  for ($i=1;$i<6;$i++) {
+    variable_del('googleanalytics_custom_var_'. $i .'_name');
+    variable_del('googleanalytics_custom_var_'. $i .'_value');
+    variable_del('googleanalytics_custom_var_'. $i .'_scope');
 }
+}
 
 /**
  * Remove cache directory if module is disabled (or uninstalled).
Index: contributions/modules/google_analytics/googleanalytics.module
--- contributions/modules/google_analytics/googleanalytics.module Base (1.19.2.11)
+++ contributions/modules/google_analytics/googleanalytics.module Locally Modified (Based On 1.19.2.11)
@@ -153,6 +153,24 @@
     $codesnippet_before = variable_get('googleanalytics_codesnippet_before', '');
     $codesnippet_after = variable_get('googleanalytics_codesnippet_after', '');
 
+    // Add custom var
+    $custom_var = '';
+    for ($i=1;$i<6;$i++) {
+      $custom_var_name = variable_get('googleanalytics_custom_var_'. $i .'_name', '');
+      if ($custom_var_name!='') {
+        $custom_var_name = drupal_to_js($custom_var_name);
+        $custom_var_value = drupal_to_js(variable_get('googleanalytics_custom_var_'. $i .'_value', ''));
+        $custom_var_scope = drupal_to_js(variable_get('googleanalytics_custom_var_'. $i .'_scope', ''));
+        if (module_exists('token')) {
+          $node = menu_get_object();
+          $custom_var .= token_replace('pageTracker._setCustomVar('. $i .','. $custom_var_name .','. $custom_var_value .','. $custom_var_scope .');', 'node', $node);
+        }
+        else {
+          $custom_var .= 'pageTracker._setCustomVar('. $i .','. $custom_var_name .','. $custom_var_value .','. $custom_var_scope .');';
+        }
+      }
+    }
+    
     // Build tracker code for footer.
     $script = 'try{';
     $script .= 'var pageTracker = _gat._getTracker('. drupal_to_js($id) .');';
@@ -162,6 +180,9 @@
     if (!empty($codesnippet_before)) {
       $script .= $codesnippet_before;
     }
+    if (!empty($custom_var)) {
+      $script .= $custom_var;
+    }
     $script .= 'pageTracker._trackPageview('. $url_custom .');';
     if (!empty($codesnippet_after)) {
       $script .= $codesnippet_after;
