function google_analytics_install in Google Analytics 4.x
Same name and namespace in other branches
- 8.3 google_analytics.install \google_analytics_install()
- 8.2 google_analytics.install \google_analytics_install()
Implements hook_install().
File
- ./
google_analytics.install, line 14 - Installation file for Google Analytics module.
Code
function google_analytics_install() {
// Make the default install more user and GDPR friendly.
$role = Role::load('authenticated');
$role
->grantPermission('opt-in or out of google analytics tracking');
$success = $role
->save();
if ($success) {
$messenger = \Drupal::messenger();
$messenger
->addMessage(t('Module %module granted %permission permission to authenticated users.', [
'%module' => 'Google Analytics',
'%permission' => t('Opt-in or out of tracking'),
]), 'status');
}
}