Commit 72c50491 authored by hass's avatar hass
Browse files

Code cleanup: Removed deprecated segmentation code.

parent 871b5643
......@@ -195,38 +195,7 @@ function googleanalytics_admin_settings_form(&$form_state) {
'#default_value' => variable_get('googleanalytics_privacy_donottrack', 1),
);
// Backward compatibility only.
// TODO: If currently not in use, hide the UI and later remove the code.
$segmentation = variable_get('googleanalytics_segmentation', array());
if (!empty($segmentation) || variable_get('googleanalytics_segmentation_DEPRECATED', FALSE)) {
$profile_enabled = module_exists('profile');
$form['segmentation'] = array(
'#type' => 'fieldset',
'#title' => t('User segmentation settings'),
'#collapsible' => TRUE,
);
// Compile a list of fields to show.
$fields = variable_get('googleanalytics_segmentation_default_fields', array('roles' => t('User roles')));
if ($profile_enabled) {
$result = db_query('SELECT name, title FROM {profile_fields} ORDER BY weight');
while ($record = db_fetch_object($result)) {
$fields[$record->name] = $record->title;
}
}
$form['segmentation']['googleanalytics_segmentation'] = array(
'#type' => 'select',
'#title' => t('Add segmentation information to tracking code') . ' <span class="admin-disabled">***DEPRECATED***</span>',
'#description' => t('Segment users based on different properties, additionally to the basic IP address based tracking provided by Google Analytics.') . ' <span class="admin-disabled">' . t('For most situations, Google recommend that you use Custom Variables to segment your visitors.') . '</span>' . (!$profile_enabled ? ' '. t('<a href="@module_list">Enable the profile module</a> to be able to use profile fields for more granular tracking.', array('@module_list' => url('admin/build/modules'))) : '') .' '. t('Make sure you will not associate (or permit any third party to associate) any data gathered from Your Website(s) (or such third parties\' website(s)) with any personally identifying information from any source as part of Your use (or such third parties\' use) of the Google Analytics service. For more information see section 8.1 in the <a href="@ga_tos">Google Analytics terms of use</a>.', array('@ga_tos' => 'http://www.google.com/analytics/en-GB/tos.html')) .' '. t('You can select multiple values.'),
'#default_value' => $segmentation,
'#options' => $fields,
'#size' => count($fields)>3 ? 10 : 3,
'#multiple' => TRUE
);
}
// Custom variables
$form['googleanalytics_custom_var'] = array(
'#collapsed' => TRUE,
'#collapsible' => TRUE,
......
......@@ -11,7 +11,6 @@ function googleanalytics_uninstall() {
variable_del('googleanalytics_codesnippet_before');
variable_del('googleanalytics_codesnippet_after');
variable_del('googleanalytics_domain_mode');
variable_del('googleanalytics_segmentation');
variable_del('googleanalytics_trackoutgoing');
variable_del('googleanalytics_trackmailto');
variable_del('googleanalytics_trackfiles');
......@@ -30,9 +29,10 @@ function googleanalytics_uninstall() {
variable_del('googleanalytics_privacy_donottrack');
variable_del('googleanalytics_translation_set');
// Remove backup variables if exits. Remove this code in D8.
// Remove backup variables if exists. Remove this code in D8.
variable_del('googleanalytics_codesnippet_before_backup_6300');
variable_del('googleanalytics_codesnippet_after_backup_6300');
variable_del('googleanalytics_segmentation');
}
/**
......
......@@ -109,27 +109,6 @@ function googleanalytics_footer($main = 0) {
// 3. Check if we should track the currently active user's role.
if (!empty($id) && _googleanalytics_visibility_pages() && _googleanalytics_visibility_user($user)) {
// Add User profile segmentation values.
$profile_fields = variable_get('googleanalytics_segmentation', array());
if (!empty($profile_fields)) {
if (module_exists('profile')) {
// Extend the $user object with profile data. Otherwise only 'User roles' can be tracked.
profile_load_profile($user);
}
$fields = array();
foreach ($profile_fields as $field => $title) {
$fields[$field] = is_array($user->$field) ? implode(',', $user->$field) : $user->$field;
}
// Only show segmentation variable if there are specified fields.
$segmentation = '';
if (count($fields) > 0) {
$segmentation = '_gaq.push(["_setVar", ' . drupal_to_js(implode(':', $fields)) . ']);';
}
}
// Site search tracking support.
$url_custom = '';
if (module_exists('search') && variable_get('googleanalytics_site_search', FALSE) && arg(0) == 'search' && $keys = search_get_keys()) {
......@@ -223,9 +202,6 @@ function googleanalytics_footer($main = 0) {
$script .= '_gaq.push(["_setDomainName", ' . drupal_to_js($cookie_domain) . ']);';
}
if (!empty($segmentation)) {
$script .= $segmentation;
}
if (!empty($custom_var)) {
$script .= $custom_var;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment