Skip to content

Instantly share code, notes, and snippets.

@mehdimehdi
Created November 2, 2012 20:58
Show Gist options
  • Save mehdimehdi/4004260 to your computer and use it in GitHub Desktop.
Save mehdimehdi/4004260 to your computer and use it in GitHub Desktop.
Mobile implementation
//usuall loyalty program, but hidden
var _ptq = _ptq || [];
var _punchtab_settings = {
key: "291747bccbb1e12abf93c56ecc73b03b",
language: "en",
display: "inline",
earningmap: true
};
(function() {
var pt = document.createElement('script'); pt.type = 'text/javascript'; pt.async = true;
pt.src = ('https:' == document.location.protocol ? 'https://' : 'http://') +'static.punchtab.com/js/pt.js?src=wordpress';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(pt, s);
})();
window.ptReady = window.ptReady || [];
//create your own connect experience.
window.ptReady.push(function () {
PT.event.bind("user.disconnected", function (response) {
document.getElementById("user-connected").style.display = "none";
document.getElementById("user-disconnected").style.display = "block";
});
PT.event.bind("user.connected", function (response) {
document.getElementById("user-connected").style.display = "block";
document.getElementById("user-disconnected").style.display = "none";
var random_number = Math.floor(Math.random()*1000);
_ptq.push(["view", {points: 300, ref_id:random_number}]);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment