Take the 2-minute tour ×

How can I hide the Google+ button from a visitor if he has already recommended the page. I don't want to hide it only after click, but also to leave the button hidden the next time the user visit the page.

share|improve this question
Unless the API offers some direct option for this, I'd be surprised if it were possible. –  Juhana May 20 '13 at 16:58
Check out this question: stackoverflow.com/questions/6575274/… –  Mindbreaker May 20 '13 at 17:05
Thank tou for your answers. @Mindbreaker i will look into this link and see if a can make it work and update the question. –  Dušan May 20 '13 at 17:09
add comment

2 Answers

up vote 2 down vote accepted

I would be careful hiding the button like this, it could cause a bad experience for the user to not be able to remove their +1 if they wanted to. If you're hiding it for aesthetic reasons, that is understandable - for example, if you wanted to show a message and then render a different button that follows Google+ branding and the Google+ Buttons policy.

If you wanted to do it, you could use the callback to put a cookie on the user's machine. The following demo shows a full implementation:

  <title>Demo: Hiding +1 after first click</title>

    <div id="pluscontainer"></div>
    <h1>Demo: Plus button here</h1>
      <span id="plusButton" style="display:none">
        <g:plusone size="tall" callback='cookieAdd'></g:plusone>
      <span id="plusMessage" style="display:none;" >
        You have already +1'd this page, click <button onClick='cookieDrop();'>here</button>
        to reshow the button

<script type="text/javascript">
  (function() {
    if (document.cookie != undefined && document.cookie.indexOf('enrolled=1') > -1){
      // User +1'd
      // User hasn't +1'd

  // Remove the cookie (show +1 button)
  function cookieDrop(){
    document.cookie = 'enrolled=0';

  // Add the cookie (hide +1 button)
  function cookieAdd(state){
    if (state.state == 'on'){
      document.cookie = 'enrolled=1;expires=0';
share|improve this answer
Great solution, thank you. –  Dušan May 21 '13 at 6:12
add comment

If the solution from Mindbreaker is not working you could add a trigger and save the IP address from the user who +1ed. When the visitor returns, you could simply remove the +1-button with CSS display:none.

share|improve this answer
add comment

Your Answer


