function googleanalytics_update_7200 in Google Analytics 7.2
Delete custom ga.js code snippets to prevent malfunctions in new Universal Analytics tracker. A backup of your snippets will be created.
File
- ./
googleanalytics.install, line 451 - Installation file for Google Analytics module.
Code
function googleanalytics_update_7200() {
$messages = array();
// ga.js code will cause the tracker to break. Remove custom code snippets.
$googleanalytics_codesnippet_before = variable_get('googleanalytics_codesnippet_before', '');
if (!empty($googleanalytics_codesnippet_before) && stristr($googleanalytics_codesnippet_before, '_gaq.push(')) {
variable_set('googleanalytics_codesnippet_before_backup_7200', $googleanalytics_codesnippet_before);
variable_del('googleanalytics_codesnippet_before');
drupal_set_message(Database::getConnection()
->prefixTables("A backup of your previous Google Analytics code snippet (ga.js) has been saved in database table '{variable}' as 'googleanalytics_codesnippet_before_backup_7200'. You need to manually upgrade the custom 'before' code snippet to analytics.js API."), 'warning');
$messages[] = t('Manual upgrade of custom "before" code snippet from ja.js to analytics.js API is required.');
}
$googleanalytics_codesnippet_after = variable_get('googleanalytics_codesnippet_after', '');
if (!empty($googleanalytics_codesnippet_after) && stristr($googleanalytics_codesnippet_after, '_gaq.push(')) {
variable_set('googleanalytics_codesnippet_after_backup_7200', $googleanalytics_codesnippet_after);
variable_del('googleanalytics_codesnippet_after');
drupal_set_message(Database::getConnection()
->prefixTables("A backup of your previous Google Analytics code snippet (ga.js) has been saved in database table '{variable}' as 'googleanalytics_codesnippet_after_backup_7200'. You need to manually upgrade the custom 'after' code snippet to analytics.js API."), 'warning');
$messages[] = t('Manual upgrade of custom "after" code snippet from ja.js to analytics.js API is required.');
}
return empty($messages) ? t('No custom code snippet found. Nothing to do.') : implode(' ', $messages);
}