Skip to content

Instantly share code, notes, and snippets.

@kwokaaron
Last active August 17, 2020 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwokaaron/abf2abc7c6b03e905b92126e70708f1a to your computer and use it in GitHub Desktop.
Save kwokaaron/abf2abc7c6b03e905b92126e70708f1a to your computer and use it in GitHub Desktop.
ShareASale sales tracking
<html>
<head>
<title>Rocketship checkout</title>
</head>
<body>
<div class="container">
<h1>Rocketship checkout</h1>
<p>Grab your copy of Rocketship app</p>
<a id="buy-button" class="btn btn-default buy-button">Buy Now!</a>
</div>
<script src="https://cdn.paddle.com/paddle/paddle.js"></script>
<script type="text/javascript">
Paddle.Setup({
vendor: 12345, // Your Paddle vendor ID
});
document.getElementById('buy-button').addEventListener('click', openCheckout, false);
function openCheckout() {
var thankyou_url = './thankyou.html'; // Your thank you page location
Paddle.Checkout.open({
product: 654321, // Your product or plan ID
successCallback: function (data) {
window.localStorage.setItem("checkout_data", data);
window.location.href(thankyou_url);
}
});
}
</script>
</body>
</html>
<html>
<head>
<title>Thanks for buying!</title>
</head>
<body>
<h1>Thank you!</h1>
<p>Thanks for purchasing Rocketship App. Your license key has been emailed to you.</p>
<script type="text/javascript">
var sas_mid = 12345, // Your ShareASale Merchant ID
data = window.localStorage.getItem("checkout_data"),
order_amount = (data.checkout.prices.vendor.total - data.checkout.prices.vendor.total_tax).toFixed(2),
sas_img = new Image();
sas_img.id = "_SHRSL_img_1";
sas_img.src = "https://shareasale.com/sale.cfm?v=paddle1.0&merchantid=" + sas_mid + "&amount=" + order_amount + "&tracking=" + data.checkout.id + "&skulist=" + data.product.id + "&pricelist=" + order_amount / data.product.quantity + "&quantitylist=" + data.product.quantity + "&couponcode=" + data.checkout.coupon.coupon_code + "&currency=" + data.checkout.prices.customer.currency;
sas_img.width = 1;
sas_img.height = 1;
document.body.appendChild(sas_img);
</script>
<script src="https://www.dwin1.com/19038.js" type="text/javascript" defer="defer"></script>
</body>
</html>
@sebworkspace
Copy link

So far I haven't been able to make this works, has this been tested? for example the "buy-button" should be an ID not a class. Thanks for working on this.

@kwokaaron
Copy link
Author

@cvscan Apologies for the missing attribute - this has now been amended. Yes, this should work as expected. If you're still experiencing issues integrating this, please contact our Seller Support team directly via the support icon near the bottom right of your dashboard, or email the team at sellers@paddle.com.

Thanks.

@sebworkspace
Copy link

Ok great thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment