Warning: This data is provided under the Google User Data Policy. Please review and comply with the policy. Failure to do so may result in project suspension or account suspension.

Toggle the One Tap display with cookies

In dynamically generated HTML pages, it's an easy task for you to include the g_id_onload <div> tag when the login is required, and then remove it after a user session has been established. However, how can you toggle One Tap display for your static HTML pages? In this case, you cannot change the HTML content.

One Tap can toggle its display status by checking for a cookie that you specify with the data-skip_prompt_cookie attribute. If the cookie isn't set or if the value is empty, our client library functions as normal. Otherwise, the client library stops running and One Tap won’t display.

You can set your cookie name with the following code snippet:

<div id="g_id_onload"
     data-client_id="YOUR_GOOGLE_CLIENT_ID"
     data-login_uri="https://your.domain/your_login_endpoint"
     data-skip_prompt_cookie="sid">
</div>