Skip to content

Instantly share code, notes, and snippets.

@bluepnume
Last active September 27, 2017 21:58
Show Gist options
  • Save bluepnume/c77be870ba21e76f39346c0ea40805a2 to your computer and use it in GitHub Desktop.
Save bluepnume/c77be870ba21e76f39346c0ea40805a2 to your computer and use it in GitHub Desktop.
/*
PayPal Button - Click Tracking
------------------------------
1. Pass an `onClick` callback to the PayPal Button, which will be called for any clicks
2. From there, call your preferred analytics service
*/
paypal.Button.render({
payment: function(data, actions) {
...
},
onAuthorize: function(data, actions) {
...
},
onClick: function() {
// This handler will be called for every click on the PayPal button
// Fire off any analytics beacons from here
// Google analytics example (taken from https://developers.google.com/analytics/devguides/collection/analyticsjs/events)
ga('send', {
hitType: 'event',
eventCategory: 'Checkout',
eventAction: 'button_click'
});
}
}, '#paypal-button-container');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment