The purchase script would be added on the checkout_success.php page. The add to cart script is a bit more difficult. You could probably add it to the add to cart button on the webassist/plugins/shopping_cart/add_to_cart.php page. Since that button submits the form, it might not work consistently and would have to be tested. You might be able to use the onsubmit event of the form on that same page instead of the onclick event of the button to initiate the add to cart script, which might be more consistent.