Please note that in the sample code that you pointed to, the "immediate check" is checked. This is intentional, since the first time a user encounters a login button on a page, it does not work.
The reason this fails is because when the page loads first, before the user even clicks the button, a request is sent to Google to determine if the user has already been registered (for example, through Google or another site). If they are, they don’t need to log in again, so the button should never be displayed. But if they are already in not , you will get the answer "immediate_file" and you will either have to show (or not clear) the button.
tl; dr - Don't worry about not getting an immediate error the first time you load the page. This is normal.