parse_ga4wp_auth_settings($_POST['ga4wp_auth_settings']); if (isset($ga4wp_auth_settings_save['agreement'])) { if(!empty($ga4wp_auth_settings_save['property_id'])|| !empty($ga4wp_auth_settings_save['tracking_id'])) { if(isset($ga4wp_auth_settings_save['property_id'])){ if(strpos((string)$ga4wp_auth_settings_save['property_id'],'G') !== false){ unset($ga4wp_auth_settings_save['tracking_id']); unset($ga4wp_auth_settings_save['manual_tracking']); update_option('ga4wp_auth_settings',$ga4wp_auth_settings_save); echo ''; $ga4wp_auth_settings = $ga4wp_auth_settings_save; }else{ if($ga4wp_auth_settings_save){ unset($ga4wp_auth_settings_save['tracking_id']); unset($ga4wp_auth_settings_save['manual_tracking']); update_option('ga4wp_auth_settings',$ga4wp_auth_settings_save); echo ''; $ga4wp_auth_settings = $ga4wp_auth_settings_save; }else { $errors .= __('Please complete Google Analytics Website Linking Process!','ga-for-wp-text').'
'; $ga4wp_auth_settings = $ga4wp_auth_settings_save; } } }else{ $manual_tracking = true; if(isset($ga4wp_auth_settings_save['manual_tracking'])){ if(strpos((string)$ga4wp_auth_settings_save['tracking_id'],'G') !== false){ update_option('ga4wp_auth_settings',$ga4wp_auth_settings_save); echo ''; $ga4wp_auth_settings = $ga4wp_auth_settings_save; }else{ update_option('ga4wp_auth_settings',$ga4wp_auth_settings_save); echo ''; $ga4wp_auth_settings = $ga4wp_auth_settings_save; } }else{ $errors .= __('Please confirm using manual tracking or use auto connect facility','ga-for-wp-text').'
'; if(get_option('ga4wp_auth_settings')){ delete_option('ga4wp_auth_settings'); $ga4wp_auth_settings = $ga4wp_auth_settings_save; } $ga4wp_auth_settings = $ga4wp_auth_settings_save; } } }else { $errors .= __('Please complete Google Analytics Website Linking Process!','ga-for-wp-text').'
'; if(get_option('ga4wp_auth_settings')){ delete_option('ga4wp_auth_settings'); $ga4wp_auth_settings = $ga4wp_auth_settings_save; header('Refresh:0'); } $ga4wp_auth_settings = $ga4wp_auth_settings_save; } }else { $errors .= __('Please agree with privacy policy and terms of service of plugin!','ga-for-wp-text').'
'; $ga4wp_auth_settings = $ga4wp_auth_settings_save; } } else{ if((($ga4wp_auth_settings['tracking_id']??false) || ($ga4wp_auth_settings['manual_tracking']??false)) && empty($ga4wp_auth_settings['property_id'])){ $manual_tracking = true; } if(!empty($analytics_properties)){ $manual_tracking = false; } } /* display error messages */ if (strlen($errors)> 0){ echo ''; } /* creating Authentication forms */ ?>
is_not_paying() && !(gfw_fs()->is_trial())) { ?> book

Google sign-in

'.$ga4wp_auth_settings['tracking_id'].'';?>
propertySummaries)){ foreach ( $account_summary->propertySummaries as $property ) { $api = GA4WP_Auth::get_instance()->get_google_management_api(); //if($ga4wp_data_streams = get_option('ga4wp_data_streams')){ //$web_data_streams = $ga4wp_data_streams; //}else{ $web_data_streams = $api->get_web_data_streams($property->property); //if(isset($web_data_streams->webDataStreams)&&!empty($web_data_streams->webDataStreams)){ //update_option('ga4wp_data_streams',$web_data_streams); //} //} if(isset($web_data_streams->dataStreams)&&!empty($web_data_streams->dataStreams)){ foreach ($web_data_streams->dataStreams as $web_data_stream){ $optgroup = $property->displayName; if ( ! isset( $ga_properties[ $optgroup ] ) ) { $ga_properties[ $optgroup ] = []; } if(isset($web_data_stream->webStreamData->measurementId) && !empty($web_data_stream->webStreamData->measurementId)) $ga_properties[ $optgroup ][ $web_data_stream->name . '|' . $web_data_stream->webStreamData->measurementId ] = sprintf( '%s (%s)', $web_data_stream->displayName, $web_data_stream->webStreamData->measurementId ); natcasesort( $ga_properties[ $optgroup ] ); } } } } } } if(isset($analytics_properties) && !empty($analytics_properties)&& is_array($analytics_properties)){ foreach ( $analytics_properties as $account_summary ) { if ( ! isset( $account_summary->kind, $account_summary->id, $account_summary->name, $account_summary->webProperties ) ) { continue; } if ( 'analytics#accountSummary' !== $account_summary->kind ) { continue; } foreach ( $account_summary->webProperties as $property ) { if ( ! isset( $property->kind, $property->id, $property->name ) ) { continue; } if ( 'analytics#webPropertySummary' !== $property->kind ) { continue; } $optgroup = $account_summary->name; if ( ! isset( $ga_properties[ $optgroup ] ) ) { $ga_properties[ $optgroup ] = []; } $ga_properties[ $optgroup ][ $account_summary->id . '|' . $property->id ] = sprintf( '%s (%s)', $property->name, $property->id ); natcasesort( $ga_properties[ $optgroup ] ); } } } if(isset($ga_properties) && !empty($ga_properties)){ update_option('ga_properties',$ga_properties); } ?> Choose Property for which you want to track data.
Granted scopes
'; $i = 0; $scope_c = count($scopes); foreach($scopes as $scope){ echo $scope.'
'; if(stripos($scope,'analytics') !== false){ $i++; if($i == $scope_c){ $ana = true; } } if(stripos($scope,'analytics.edit') !== false){ $ana_edit = true; } } } if(!($ana && $ana_edit)){ if(!$ana){ echo 'analytics.readonly scope
'; echo 'this scope is important because otherwise dashboard and onsite reports will not work so please provide the access of this scope
'; ?> Google sign-in
Or