تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
توضّح هذه الصفحة كيفية تنفيذ الميزات المتعلّقة بطريقة تسجيل المستخدمين الدخول أو تسجيل الخروج باستخدام ميزة "Google One Tap".
تسجيل دخول المستخدمين تلقائيًا
تتيح ميزة "نقرة واحدة" من Google ميزة "تسجيل الدخول تلقائيًا"، ما يقدّم تجربة مستخدم
سلسة من خلال إزالة الخطوات اليدوية التي يجب أن يتّخذها المستخدمون عند العودة
إلى موقعك الإلكتروني. لا يحتاج المستخدمون إلى تذكُّر حساب Google الذي اختاروه
أثناء زيارتهم الأخيرة، ما يقلل من فرص إنشاء حسابات مكرّرة
غير ضرورية على منصتك.
تهدف ميزة "تسجيل الدخول تلقائيًا" إلى أن تكون مكملاً لزر "تسجيل الدخول باستخدام حساب Google"
ومربّعات حوار OneTap. تم تصميمه ليتم استخدامه على موقعك الإلكتروني بالكامل، ولا يتم تسجيل الاشتراك يدويًا أو تبديل الحسابات إلا بعد تسجيل الخروج من موقعك الإلكتروني أولاً.
لكي تتم عملية تسجيل الدخول التلقائي، يجب استيفاء الشروط التالية:
يجب أن يكون المستخدمون مسجّلين الدخول أولاً إلى حساباتهم على Google.
قدّم موافقته سابقًا على مشاركة ملفه الشخصي على حسابه مع تطبيقك
عند استخدام FedCM، أجريت محاولة واحدة فقط لتسجيل الدخول في آخر 10 دقائق.
يتم عرض ميزة "النقرة الواحدة" عند حدوث محاولات متكرّرة لتسجيل الدخول خلال هذه الفترة.
عند استخدام FedCM، يطلب Chrome من المستخدمين إعادة تأكيد أنّهم يريدون
تسجيل الدخول إلى الموقع الإلكتروني باستخدام حساب Google في كل مثيل من Chrome حتى إذا كان
المستخدم قد وافق على الموقع الإلكتروني قبل طرح FedCM. قد يؤثر هذا التغيير في
نسبة الإحالات الناجحة على موقعك الإلكتروني الحالي الذي يستخدم ميزة "النقرة الواحدة". في تحديث Chrome M121، يؤدي تحسين ميزة "تسجيل الدخول تلقائيًا" إلى تخفيف مشكلة انخفاض معدّل الإحالات الناجحة.
بالنسبة إلى الصفحات التي تم فيها تفعيل ميزة "تسجيل الدخول تلقائيًا"، وفي حال استيفاء هذه الشروط، تتم تلقائيًا إحالة بيانات اعتماد رمز التعريف الخاص بالمستخدم بدون أي تفاعل من العميل. في حال عدم استيفاء هذه الشروط، وحتى إذا كان تسجيل الدخول التلقائي مفعّلاً
على الصفحة، سيتم توجيه المستخدم تلقائيًا إلى مسار "النقرة الواحدة" لتسجيل الدخول أو منح
الموافقة. إذا كان لدى المستخدم حسابات متعدّدة على Google وزار موقعك الإلكتروني، عليه أولاً تسجيل الدخول إلى حساب واحد على Google وتقديم الموافقة على ذلك الحساب.
يمكنك قياس معدّل نجاح ميزة "تسجيل الدخول تلقائيًا" باستخدام القيمة auto في حقل
select_by لعنصر بيانات الاعتماد الذي تم إرجاعه.
لتفعيل ميزة "تسجيل الدخول تلقائيًا"، أضِف data-auto_select="true" إلى الرمز البرمجي، كما هو موضح في المقتطف التالي:
عندما يسجّل المستخدم الخروج من موقعك الإلكتروني، يمكن توجيهه إلى صفحة يتم فيها عرض رمز تطلب منه استخدام Google One Tap تلقائيًا. في ما يتعلّق بهذا الإعداد، يجب منع الاختيار التلقائي. بخلاف ذلك، يتم تسجيل دخول المستخدم تلقائيًا مرة أخرى، ما يؤدي إلى
تجربة مستخدم غير ناجحة.
استخدام FedCM
لتحسين تجربة المستخدم، يتم تطبيق فترة هدوء مدتها 10 دقائق بين كل محاولة تسجيل دخول تلقائية. خلال هذه الفترة الزمنية، يتم بدلاً من ذلك عرض طلب One Tap. على المستخدمين النقر صراحةً على ميزة "النقرة الواحدة" لتسجيل الدخول.
بدون FedCM
لحظر الاختيار التلقائي بعد تسجيل خروج المستخدم، أضِف اسم الفئة
g_id_signout إلى جميع روابط وزرّات تسجيل الخروج. راجِع المقتطف التالي من الرمز:
<div class="g_id_signout">Sign Out</div>
يمكن أيضًا استخدام مقتطف رمز JavaScript التالي لتسجيل الخروج:
لمنع حدوث حلقة لا نهائية في تجربة المستخدم، يتم تخزين حالة تسجيل خروج المستخدم في ملف تعريف ارتباط باسم
g_state يتم ضبطه من خلال مكتبة Google Identity Services. يتم تلقائيًا ضبط
نطاق ملف تعريف الارتباط على نطاق الصفحة الحالية. إذا كان تطبيق One Tap معروضًا
على النطاق الرئيسي والنطاقات الفرعية، يجب أن يكون ملف تعريف الارتباط الخاص بالحالة مرئيًا في
جميع نطاقاتك. استخدِم السمة data-state_cookie_domain لضبط نطاق ملفّ تعريف الارتباط
g_state على نطاقك الرئيسي. على سبيل المثال، أضِف
data-state_cookie_domain="example.com" إلى عنصر g_id_onload لنطاق والد هو example.com ونطاق فرعي باسم webapp.example.com.
إذا كانت لديك خدمة تتتبّع جميع ملفات تعريف الارتباط المستخدَمة في نطاقك،
عليك إعلامها بملف تعريف الارتباط g_state.
إذا كنت لا تريد تحميل مكتبة العميل على صفحات ما بعد تسجيل الدخول، استخدِم
هذه الحلول لمنع حدوث تجربة مستخدم متكرّرة بعد تسجيل الخروج:
عند تسجيل الخروج، أعِد توجيه المستخدمين إلى صفحة (مثل
https://example.com/logged_out) لا يتم فيها عرض ميزة "النقرة الواحدة"، أو
حيث يكون تسجيل الدخول التلقائي غير مفعّل دائمًا.
عند تسجيل الخروج، أضِف مَعلمة إلى عنوان URL. مثلاً: logged_out=1
عند عرض واجهة برمجة التطبيقات One Tap by JavaScript، تحقّق من مَعلمة عنوان URL هذه
وأوقِف ميزة "تسجيل الدخول تلقائيًا" إذا كانت متوفّرة.
تجارب المستخدمين الرئيسية
صفحة تسجيل الدخول التلقائي
استخدام FedCM
يمكن للمستخدمين إغلاق طلب One Tap بالنقر على الزر X. مراعاةً لسهولة الاستخدام، تتم مشاركة رمز تعريف مع موقعك الإلكتروني
حتى إذا نقر المستخدمون على الزر X.
لتحسين تجربة المستخدم، يتم تطبيق فترة هدوء مدتها 10 دقائق بين كل محاولة تسجيل دخول تلقائية. خلال هذه الفترة الزمنية، يتم بدلاً من ذلك عرض طلب One Tap. على المستخدمين النقر صراحةً على ميزة "النقرة الواحدة" لتسجيل الدخول.
بدون FedCM
إذا لم ينقر المستخدمون على الزر إلغاء خلال 5 ثوانٍ، تتم مشاركة رمز تعريف
مع موقعك الإلكتروني.
عند إلغاء تسجيل الدخول، استنادًا إلى عدد جلسات Google النشطة،
يتم عرض صفحة اختيار الحساب أو صفحة المستخدم المتكرّر.
تاريخ التعديل الأخير: 2025-05-23 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-05-23 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eGoogle One Tap enables automatic sign-in, providing a frictionless user experience by eliminating manual login steps for returning users.\u003c/p\u003e\n"],["\u003cp\u003eAutomatic sign-in works when users are signed in to their Google Account, have previously granted consent, and (for FedCM) haven't attempted sign-in within the last 10 minutes.\u003c/p\u003e\n"],["\u003cp\u003eTo enable automatic sign-in, add \u003ccode\u003edata-auto_select="true"\u003c/code\u003e to your One Tap implementation code.\u003c/p\u003e\n"],["\u003cp\u003eWhen implementing sign-out functionality, ensure auto-selection is disabled to prevent a login loop, which can be achieved by using the \u003ccode\u003eg_id_signout\u003c/code\u003e class or \u003ccode\u003egoogle.accounts.id.disableAutoSelect()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eOne Tap sign-out (disabling automatic sign-in) is temporary and does not sign users out of your website or Google services.\u003c/p\u003e\n"]]],[],null,["# Automatic sign-in and sign-out\n\nThis page describes how to implement features related to how users sign in or\nsign out with Google One Tap.\n\nSign in users automatically\n---------------------------\n\nGoogle One Tap supports automatic sign-in, which provides a frictionless user\nexperience (UX) by removing the manual steps users must take when returning\nto your site. Users don't need to remember which Google Account they selected\nduring their last visit, decreasing the chances of unnecessary duplicate\naccounts being created on your platform.\n\nAutomatic sign-in is intended to complement our Sign in with Google button\nand One Tap dialogs. It is designed to be used across your entire site, with\nmanual sign-up or switching accounts occurring only after the user has first\nsigned-out of your site.\n\nFor Automatic sign-in to occur the following conditions are required:\n\n- users must first be signed-in to their Google Account, and\n- previously granted consent to share their account profile with your app, and\n- when using FedCM, made only a single sign-in attempt in the last 10 minutes. One Tap is displayed when repeated sign-in attempts occur during this window.\n- when using FedCM, Chrome requires users to reconfirm that they want to sign in to the website with Google Account in each Chrome instance even if the user approved the website prior to the FedCM rollout. This change may affect conversion rate on your existing site using One Tap. In Chrome M121 update, [Auto Sign-in improvement](/identity/gsi/web/reference/release-notes#2023-12-21) mitigates conversion rate drop issue.\n\nFor pages where Automatic sign-in is enabled and if these conditions are met\nthe user's ID token credential is automatically returned without any user\ninteraction. If these conditions are not met, and even if Automatic sign-in is\nenabled on the page, the user defaults to the One Tap flow for sign-in or\nconsent. If a user has multiple Google Accounts and visits your site they are\nrequired to first sign-in to a single Google Account and to have provided\nconsent for that account.\n\nYou may measure Automatic sign-in success rate using the `auto` value in the\n[select_by](/identity/gsi/web/reference/js-reference#select_by) field of the returned credential object.\n\nTo enable automatic sign-in, add `data-auto_select=\"true\"` to your code, as\nshown in the following snippet: \n\n \u003cdiv id=\"g_id_onload\"\n data-client_id=\"\u003cvar translate=\"no\"\u003eYOUR_GOOGLE_CLIENT_ID\u003c/var\u003e\"\n data-login_uri=\"\u003cvar translate=\"no\"\u003ehttps://your.domain/your_login_endpoint\u003c/var\u003e\"\n data-auto_select=\"true\"\u003e\n \u003c/div\u003e\n\n| **Note:** The [upgraded One Tap UX for ITP browsers](/identity/gsi/web/guides/features#upgraded_ux_on_itp_browsers) doesn't support auto sign-in.\n\nSign out\n--------\n\nWhen a user signs out of your website, they can be directed to a page where a\nGoogle One Tap prompt is automatically displayed. For this setup, auto-selection\nmust be prohibited. Otherwise, the user is automatically signed in again, which\nleads to a dead-loop UX. \n\n### Using FedCM\n\nTo improve user experience, there is a 10 minute quiet period between every\nautomatic sign-in attempt. During this time period, One Tap prompt is\ndisplayed instead. Users need to explicitly click One Tap to sign in.\n\n### Without FedCM\n\nTo prohibit auto-selection after a user signs out, add the class name\n`g_id_signout` to all of your logout links and buttons. See the following code\nsnippet: \n\n \u003cdiv class=\"g_id_signout\"\u003eSign Out\u003c/div\u003e\n\nThe following JavaScript code snippet can also be used for sign out: \n\n const button = document.getElementById('signout_button');\n button.onclick = () =\u003e {\n google.accounts.id.disableAutoSelect();\n }\n\nTo prevent a dead-loop UX, user signed-out status is stored in a cookie named\n`g_state` that is set by the Google Identity Services library. By default the\ncookie domain is set to the domain of current page. If One Tap is displayed\non the parent domain and subdomains, the state cookie must be visible across\nall of your domains. Use the `data-state_cookie_domain` attribute to set the\n`g_state` cookie domain to your parent domain. For example, add\n`data-state_cookie_domain=\"example.com\"` to the `g_id_onload` element for a\nparent domain of `example.com` and a subdomain named `webapp.example.com`.\n| **Key Point:** If One Tap is displayed on multiple domains, you need to set the `g_state` cookie domain to your parent domain.\n\nIf you have a service that monitors all of the cookies used in your domain,\nyou need to notify them of the `g_state` cookie.\n| **Key Point:** Feel free to use other ways to prevent the dead-loop UX on log out moment.\n\nIf you don't want to load the client library on your post-login pages, use\nthese solutions to prevent a dead-loop UX after log out occurs:\n\n- On log out, redirect users to a page (say, `https://example.com/logged_out`) where One Tap is not displayed, or where auto sign-in is always disabled.\n- On log out, add a parameter to the URL. For example, `logged_out=1`. When rendering One Tap by JavaScript API, check that URL parameter and disable auto sign-in when present.\n\n| **Warning:** The term 'sign out' here refers to temporarily disabling One Tap Automatic sign-in for one day. This API does not sign out your users out of your website or any Google websites.\n\nKey user journeys\n-----------------\n\nThe automatic sign-in page. \n\n### Using FedCM\n\nUsers can close the One Tap prompt by clicking the **X** button. For\naccessibility consideration, an ID token is shared with your website\neven if users click the **X** button.\n\nTo improve user experience, there is a 10 minute quiet period between every\nautomatic sign-in attempt. During this time period, One Tap prompt is\ndisplayed instead. Users need to explicitly click One Tap to sign in.\n\n### Without FedCM\n\nIf users don't click the **Cancel** button within 5 seconds, an ID token\nis shared with your website.\n\nWhen Sign-In is cancelled, based on the number of active Google sessions,\neither the account chooser page or the returning user page displays.\n\n- Multiple Google sessions\n\n- Single Google Sessions\n\n| **Key Point:** Once cancelled, Automatic sign-in is disabled for one day."]]