diff --git a/includes/data-events/connectors/ga4/README.md b/includes/data-events/connectors/ga4/README.md index 4373472d6c..4dd4031bc7 100644 --- a/includes/data-events/connectors/ga4/README.md +++ b/includes/data-events/connectors/ga4/README.md @@ -26,6 +26,7 @@ These parameters are added to all events: * `ga_session_id`: The GA Session ID, retrieved from the cookie * `logged_in`: Whether the user is logged in when the event got fired * `is_reader`: Whether the user is a RAS reader +* `email_hash`: The anonymized user email, if the user is logged in Note: All paramaters are strings diff --git a/includes/data-events/connectors/ga4/class-ga4.php b/includes/data-events/connectors/ga4/class-ga4.php index 28d2fa7fb5..3859c5850a 100644 --- a/includes/data-events/connectors/ga4/class-ga4.php +++ b/includes/data-events/connectors/ga4/class-ga4.php @@ -189,8 +189,9 @@ public static function filter_event_body( $body, $event_name ) { $body['data']['ga_params']['is_reader'] = 'no'; if ( is_user_logged_in() ) { - $current_user = wp_get_current_user(); - $body['data']['ga_params']['is_reader'] = Reader_Activation::is_user_reader( $current_user ) ? 'yes' : 'no'; + $current_user = wp_get_current_user(); + $body['data']['ga_params']['is_reader'] = Reader_Activation::is_user_reader( $current_user ) ? 'yes' : 'no'; + $body['data']['ga_params']['email_hash'] = md5( $current_user->user_email ); } return $body;