Skip to content

Commit

Permalink
feat: add anonymized email to ga4 events (#2585)
Browse files Browse the repository at this point in the history
* feat: add anonymized email to ga4 events

* feat: rename property
  • Loading branch information
leogermani authored Aug 21, 2023
1 parent 0784c69 commit 9ac1c33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions includes/data-events/connectors/ga4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions includes/data-events/connectors/ga4/class-ga4.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9ac1c33

Please sign in to comment.