'Unauthorized'), 403); } $awca_auth_settings_save = AWCA_Settings::get_instance()->parse_awca_auth_settings($_POST['awca_auth_settings']); if (isset($awca_auth_settings_save['agreement'])) { if (!empty($awca_auth_settings_save['property_id']) || !empty($awca_auth_settings_save['tracking_id'])) { if (isset($awca_auth_settings_save['property_id'])) { if (strpos((string)$awca_auth_settings_save['property_id'], 'G') !== false) { unset($awca_auth_settings_save['tracking_id']); unset($awca_auth_settings_save['manual_tracking']); update_option('awca_auth_settings', $awca_auth_settings_save); echo ''; $awca_auth_settings = $awca_auth_settings_save; } else { if ($awca_auth_settings_save) { unset($awca_auth_settings_save['tracking_id']); unset($awca_auth_settings_save['manual_tracking']); update_option('awca_auth_settings', $awca_auth_settings_save); echo ''; $awca_auth_settings = $awca_auth_settings_save; } else { $errors .= 'Please complete Google Analytics Website Linking Process!
'; $awca_auth_settings = $awca_auth_settings_save; } } } else { $manual_tracking = true; if (isset($awca_auth_settings_save['manual_tracking'])) { if (strpos((string)$awca_auth_settings_save['tracking_id'], 'G') !== false) { update_option('awca_auth_settings', $awca_auth_settings_save); echo ''; $awca_auth_settings = $awca_auth_settings_save; } else { update_option('awca_auth_settings', $awca_auth_settings_save); echo ''; $awca_auth_settings = $awca_auth_settings_save; } } else { $errors .= 'Please confirm using manual tracking or use auto connect facility
'; if (get_option('awca_auth_settings')) { delete_option('awca_auth_settings'); $awca_auth_settings = $awca_auth_settings_save; } $awca_auth_settings = $awca_auth_settings_save; } } } else { $errors .= 'Please complete Google Analytics Website Linking Process!
'; if (get_option('awca_auth_settings')) { delete_option('awca_auth_settings'); $awca_auth_settings = $awca_auth_settings_save; header('Refresh:0'); } $awca_auth_settings = $awca_auth_settings_save; } } else { $errors .= 'Please agree with privacy policy and terms of service of plugin!
'; $awca_auth_settings = $awca_auth_settings_save; } } else { if ((($awca_auth_settings['tracking_id'] ?? false) || ($awca_auth_settings['manual_tracking'] ?? false)) && empty($awca_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 */ ?>

Google sign-in

' . $awca_auth_settings['tracking_id'] . ''; ?>
propertySummaries)) { foreach ($account_summary->propertySummaries as $property) { $api = AWCA_Auth::get_instance()->get_google_management_api(); //if($awca_data_streams = get_option('awca_data_streams')){ //$web_data_streams = $awca_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('awca_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
analytics.edit scope
'; echo 'this scope is important which help to measurement secret key for some important information transfer to google analytics and als0 creating custom dimension creation which is used for form conversion tracking, author tracking, content tracking and many more purposes
'; } echo '
please start relink process to provide all requested scopes for AWCA plugin
'; //update_option('awca_refresh_token_fail','yes'); //delete_option('awca_granted_scopes');*/ } else { delete_option('awca_refresh_token_fail'); } ?>