Skip to content

Instantly share code, notes, and snippets.

@mehdimehdi
Created July 19, 2012 18:53
Show Gist options
  • Save mehdimehdi/3145971 to your computer and use it in GitHub Desktop.
Save mehdimehdi/3145971 to your computer and use it in GitHub Desktop.
Integrate Google Analytics with PunchTab
window.ptReady = window.ptReady || [];
var _gaq = _gaq || [];
//this is instantiated when PT is loaded.
window.ptReady.push(function () {
//add the custom variable for the members so you can segment them.
PT.event.bind("user.connected", function (response) {
if (response.newUser) {
_gaq.push(['_trackEvent',
'member', // category of activity
'signup', // Action
]);
}
_gaq.push(['_setCustomVar',
1, // This custom var is set to slot #1. Required parameter.
'member', // The name acts as a kind of category for the user activity. Required parameter.
'True' // This value of the custom variable. Required parameter.
]);
});
PT.event.bind("user.disconnected", function (response) {
_gaq.push(['_setCustomVar',
1, // This custom var is set to slot #1. Required parameter.
'member', // The name acts as a kind of category for the user activity. Required parameter.
'False' // This value of the custom variable. Required parameter.
]);
});
PT.event.bind("twitter.tweet", function (response) {
_gaq.push(['_trackEvent',
'sharing', // category of activity
'tweet', // Action
]);
});
PT.event.bind("facebook.like", function (response) {
_gaq.push(['_trackEvent',
'sharing', // category of activity
'like', // Action
]);
});
PT.event.bind("google.plusone", function (response) {
_gaq.push(['_trackEvent',
'sharing', // category of activity
'+1', // Action
]);
});
PT.event.bind("loyalty.earned", function (response) {
_gaq.push(['_trackEvent',
'loyalty', // category of activity
'earned', // Action
]);
});
PT.event.bind("loyalty.redeemed", function (response) {
if (response.id === 2) {//need to be upadted with the right prize id
_gaq.push(['_trackEvent',
'loyalty', // category of activity
'tastemaker', // Action
]);
}//do this for all the kind of redemptions
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment