summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--googleanalytics.admin.inc4
-rw-r--r--googleanalytics.module17
2 files changed, 9 insertions, 12 deletions
diff --git a/googleanalytics.admin.inc b/googleanalytics.admin.inc
index 30159de..d9efe91 100644
--- a/googleanalytics.admin.inc
+++ b/googleanalytics.admin.inc
@@ -114,7 +114,7 @@ function googleanalytics_admin_settings_form(&$form_state) {
// 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, type, weight FROM {profile_fields} ORDER BY weight');
+ $result = db_query('SELECT name, title FROM {profile_fields} ORDER BY weight');
while ($record = db_fetch_object($result)) {
$fields[$record->name] = $record->title;
}
@@ -124,7 +124,7 @@ function googleanalytics_admin_settings_form(&$form_state) {
'#type' => 'select',
'#title' => t('Add segmentation information to tracking code'),
'#description' => t('Segment users based on different properties, additionally to the basic IP address based tracking provided by Google Analytics.') . (!$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('Selecting one or more values is supported. To select multiple items, hold down CTRL (PC) or &#8984; (Mac) while selecting fields.'),
- '#default_value' => variable_get('googleanalytics_segmentation', ''),
+ '#default_value' => variable_get('googleanalytics_segmentation', array()),
'#options' => $fields,
'#size' => count($fields)>3 ? 10 : 3,
'#multiple' => TRUE
diff --git a/googleanalytics.module b/googleanalytics.module
index 4a79326..acea649 100644
--- a/googleanalytics.module
+++ b/googleanalytics.module
@@ -96,19 +96,16 @@ function googleanalytics_footer($main = 0) {
if (!empty($id) && _googleanalytics_visibility_pages() && _googleanalytics_visibility_user($user)) {
// Add User profile segmentation values.
- if (is_array($profile_fields = variable_get('googleanalytics_segmentation', '')) && ($user->uid > 0)) {
-
- $p = module_invoke('profile', 'load_profile', $user);
+ $profile_fields = variable_get('googleanalytics_segmentation', array());
+ if (!empty($profile_fields) && ($user->uid > 0)) {
+ // 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('load_profile', $user);
$fields = array();
foreach ($profile_fields as $field => $title) {
- $value = $user->$field;
-
- if (is_array($value)) {
- $value = implode(',', $value);
- }
-
- $fields[$field] = $value;
+ $fields[$field] = is_array($user->$field) ? implode(',', $user->$field) : $user->$field;
}
// Only show segmentation variable if there are specified fields.