Quantcast
Channel: The Gumroad Blog
Viewing all articles
Browse latest Browse all 255

Listen for Purchases Within the Gumroad Overlay

$
0
0

You can now listen for purchases being made within the Gumroad overlay and embed widgets.

Here is some sample JavaScript on how to do that:

     listener = function(ev) {
       if (ev.data && JSON.parse(ev.data).post_message_name == “sale”) {
         document.getElementById(‘post-message-data’).innerHTML = ev.data;
       }
     }
     window.addEventListener('message’, listener, false);

That’s it! As long as the Gumroad JS is included in your webpage, you can listen for `sale` events and react accordingly. For example, you could redirect the user to a custom thank you page.

To recap, we have launched:

  • a zipper JS include (just 8 kb)
  • this new PostMessage hook
  • more API endpoints for subscriptions, refunds, and disputes
  • ability to subscribe without creating a Gumroad account

All to make it easier to build custom experiences with Gumroad!

Over 25% of purchases on Gumroad happen on a creator’s website, with a custom integration. We hope that as creators grow and want more custom experiences, we will be able to scale with them.

Happy creating!


Viewing all articles
Browse latest Browse all 255

Trending Articles