Set up webhooks in Paddle
In order for Metricks to be able to read the transaction information from your Paddle-powered subscriptions, you need to have webhooks set up.
In Paddle, go to Developer tools > Events and make sure the following events have "Webhook" turned on:
Subscription Created
Subscription Updated
Subscription Cancelled
Subscription Payment Success
Subscription Payment Refunded
You can also add a new webhook by clicking on '+ Add a new endpoint'
If you already have Paddle's webhooks set up in your app, just make sure that the events listed above are checked. You do not need to do anything else.
If you do not already have Paddle's webhooks set up in your app, make sure you use the Metricks webhook URL;
https://api.metricks.io/api/v1/paddle/webhook
and paste it into the "URL for receiving webhook alerts" field in the same Alerts / Webhooks page in Paddle, and click Save.
Record affiliates from your site
You’ll need to add Metricks Javascript library to all the pages in your website.
<script>
!function(e,t,n,a,c,s,r){e[a]||((c=e[a]=function(){c.process?c.process.apply(c,arguments):c.queue.push(arguments)}).queue=[],c.t=+new Date,(s=t.createElement(n)).async=1,s.src="https://script.metricks.io/tracker.min.js?t="+864e5*Math.ceil(new Date/864e5),(r=t.getElementsByTagName(n)[0]).parentNode.insertBefore(s,r))}(window,document,"script","metr"),metr("init","YOUR_API_KEY"),metr("integration","paddle");
</script>
Make sure to replace YOUR_API_KEY with your actual Metricks API Key.
Pass the Affiliate Id to Paddle
You will need to pass the Affiliate Id to your Paddle JS library. Affiliate Id is in this format yourdomain.com/?ref=AffiliateId.
The setup will look like this.
<script src="https://cdn.paddle.com/paddle/paddle.js"></script>
<script type="text/javascript">
Paddle.Setup({
vendor: 123456789,
passthrough: '{"metrAffiliate": AFFILIATE_ID}',
});
</script>
You can also use the below function to get the Affiliate ID.
const AFFILIATE_ID = metr.affiliateId;