function googleanalytics_update_7002 in Google Analytics 7.2
Same name and namespace in other branches
- 7 googleanalytics.install \googleanalytics_update_7002()
Upgrade "User roles" tracking to custom variables.
File
- ./
googleanalytics.install, line 351 - Installation file for Google Analytics module.
Code
function googleanalytics_update_7002() {
// Read previous segmentation settings.
$segmentation = variable_get('googleanalytics_segmentation', array());
// If this is an upgrade from D6 the slot 1 may not empty.
if (empty($googleanalytics_custom_vars['slots'][1]) && in_array('roles', $segmentation)) {
// Upgrade previous segmentation settings to new custom variables settings.
$googleanalytics_custom_vars = variable_get('googleanalytics_custom_var', array());
$googleanalytics_custom_vars['slots'][1]['slot'] = 1;
$googleanalytics_custom_vars['slots'][1]['name'] = 'User roles';
$googleanalytics_custom_vars['slots'][1]['value'] = '[current-user:role-names]';
// Sets the scope to visitor-level.
$googleanalytics_custom_vars['slots'][1]['scope'] = 1;
variable_set('googleanalytics_custom_var', $googleanalytics_custom_vars);
return t('The deprecated profile segmentation setting for "User roles" has been added to custom variables. You need to deselect all selected profile fields in <a href="@admin">Google Analytics settings</a> and upgrade other profile fields manually or you may lose tracking data in future! See Google Analytics <a href="@customvar">Custom Variables</a> for more information.', array(
'@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables',
'@admin' => url('admin/config/system/googleanalytics'),
));
}
else {
return t('You need to deselect all selected profile fields in <a href="@admin">Google Analytics settings</a> and upgrade other profile fields manually or you may lose tracking data in future! See Google Analytics <a href="@customvar">Custom Variables</a> for more information.', array(
'@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables',
'@admin' => url('admin/config/system/googleanalytics'),
));
}
}