diff --git a/google_analytics.install b/google_analytics.install index 259bf2c19692612ff03fda3c8893a74422fc7eb6..d9bd9c97e73ec1a6ee15dc9ee708b6bcdb4546a4 100644 --- a/google_analytics.install +++ b/google_analytics.install @@ -6,6 +6,20 @@ */ use Drupal\Core\Url; +use Drupal\user\Entity\Role; + +/** + * Implements hook_install(). + */ +function google_analytics_install() { + // Make the default install more user and GDPR friendly. + $role = Role::load('authenticated'); + $role->grantPermission('opt-in or out of matomo tracking'); + $success = $role->save(); + if ($success) { + drupal_set_message(t('Module %module granted %permission permission to authenticated users.', ['%module' => 'Matomo Analytics', '%permission' => t('Opt-in or out of tracking')]), 'status'); + } +} /** * Implements hook_uninstall().