Skip to content

Instantly share code, notes, and snippets.

@boertel
Last active December 18, 2015 11:39
Show Gist options
  • Save boertel/5776843 to your computer and use it in GitHub Desktop.
Save boertel/5776843 to your computer and use it in GitHub Desktop.
Get referral link
var _ptq = _ptq || [];
var _punchtab_settings = {
key: "<YOUR KEY>",
display: "tab"
};
(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';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(pt, s);
})();
window.ptReady = window.ptReady || [];
window.ptReady.push(function () {
PT.referral.getUrl(document.location.href, function (response) {
console.log(response); // contains response.longUrl (punchtab.com link) and response.shortUrl (ptab.it link)
}, true); // ask for short url
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment