Let's say I have a webpage and I have added the 1+ button.
Is there a good way to tell if the user has already pressed the 1+ button on a previous visit.
I'd like to present a thank you on all the viewers visit if they've 1+ the page.
In the +1 API there is a callback
method which you can use to trap +1's
A strategy would be to trap these calls and store a cookie on the browser. Next time the user comes, you can check the cookie and show the thanks message.
From the docs
callback The identifier for a function in the global namespace
Called after the user has clicked the +1 button. The callback function may accept a JSON object which will be of the form, {"href": "http://www.example.com/", "state": "on"}. Where href is the URL of the +1 and state is on for a +1 and off for the removal of a +1.
A quick example:
function plus1Callback(params)
{
if(params.state == "on"){
setCookie("hasplus1", "true");
}
}
function checkHasPlus1()
{
var hasplus1=getCookie("hasplus1");
if (hasplus1!=null && hasplus1!=""){
alert("Thanks for your +1");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With