Commit a52d9f2d authored by hass's avatar hass
Browse files

Code cleanup: Removed deprecated segmentation code.

parent dd9cda12
...@@ -268,38 +268,7 @@ function googleanalytics_admin_settings_form($form_state) { ...@@ -268,38 +268,7 @@ function googleanalytics_admin_settings_form($form_state) {
'#default_value' => variable_get('googleanalytics_privacy_donottrack', 1), '#default_value' => variable_get('googleanalytics_privacy_donottrack', 1),
); );
// Backward compatibility only. // Custom variables.
// 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('Additional user information'),
'#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_field} ORDER BY weight');
foreach ($result as $record) {
$fields[$record->name] = $record->title;
}
}
$form['segmentation']['googleanalytics_segmentation'] = array(
'#type' => 'select',
'#title' => t('Segment users based on these selected properties') . ' <span class="admin-disabled">***DEPRECATED***</span>',
'#description' => t("You can supplement Google Analytics' basic IP address tracking of visitors by segmenting users based on these selected properties.") . ' <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('Section 7 of the <a href="@ga_tos">Google Analytics terms of service</a> requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'http://www.google.com/analytics/terms/gb.html')) . ' ' . t('You can select multiple values.'),
'#default_value' => $segmentation,
'#options' => $fields,
'#size' => count($fields)>3 ? 10 : 3,
'#multiple' => TRUE,
);
}
$form['googleanalytics_custom_var'] = array( $form['googleanalytics_custom_var'] = array(
'#collapsed' => TRUE, '#collapsed' => TRUE,
'#collapsible' => TRUE, '#collapsible' => TRUE,
......
...@@ -35,7 +35,6 @@ function googleanalytics_uninstall() { ...@@ -35,7 +35,6 @@ function googleanalytics_uninstall() {
variable_del('googleanalytics_last_cache'); variable_del('googleanalytics_last_cache');
variable_del('googleanalytics_pages'); variable_del('googleanalytics_pages');
variable_del('googleanalytics_roles'); variable_del('googleanalytics_roles');
variable_del('googleanalytics_segmentation');
variable_del('googleanalytics_site_search'); variable_del('googleanalytics_site_search');
variable_del('googleanalytics_trackadsense'); variable_del('googleanalytics_trackadsense');
variable_del('googleanalytics_trackdoubleclick'); variable_del('googleanalytics_trackdoubleclick');
...@@ -48,9 +47,10 @@ function googleanalytics_uninstall() { ...@@ -48,9 +47,10 @@ function googleanalytics_uninstall() {
variable_del('googleanalytics_visibility_pages'); variable_del('googleanalytics_visibility_pages');
variable_del('googleanalytics_visibility_roles'); variable_del('googleanalytics_visibility_roles');
// Remove backup variables if exits. Remove this code in D8. // Remove backup variables if exist. Remove this code in D8.
variable_del('googleanalytics_codesnippet_after_backup_6300'); variable_del('googleanalytics_codesnippet_after_backup_6300');
variable_del('googleanalytics_codesnippet_before_backup_6300'); variable_del('googleanalytics_codesnippet_before_backup_6300');
variable_del('googleanalytics_segmentation');
} }
/** /**
......
...@@ -146,26 +146,6 @@ function googleanalytics_page_alter(&$page) { ...@@ -146,26 +146,6 @@ function googleanalytics_page_alter(&$page) {
} }
} }
// Add User profile segmentation values.
$profile_fields = variable_get('googleanalytics_segmentation', array());
if (!empty($profile_fields)) {
// Invoke all modules having a hook_user_load() implemented.
// If the invoked modules extend the $user object, the additional
// data can be tracked.
module_invoke_all('user_load', array($user->uid => $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_json_encode(implode(':', $fields)) . ']);';
}
}
// Site search tracking support. // Site search tracking support.
$url_custom = ''; $url_custom = '';
if (module_exists('search') && variable_get('googleanalytics_site_search', FALSE) && arg(0) == 'search' && $keys = googleanalytics_search_get_keys()) { if (module_exists('search') && variable_get('googleanalytics_site_search', FALSE) && arg(0) == 'search' && $keys = googleanalytics_search_get_keys()) {
...@@ -260,9 +240,6 @@ function googleanalytics_page_alter(&$page) { ...@@ -260,9 +240,6 @@ function googleanalytics_page_alter(&$page) {
$script .= '_gaq.push(["_setAllowLinker", true]);'; $script .= '_gaq.push(["_setAllowLinker", true]);';
} }
if (!empty($segmentation)) {
$script .= $segmentation;
}
if (!empty($custom_var)) { if (!empty($custom_var)) {
$script .= $custom_var; $script .= $custom_var;
} }
......
Markdown is supported
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