Listen to the 'form submit' event (to measure conversion via an analytics tool)


Use case

  • A merchant wants to measure conversion via an analytics tool.
  • It's hard to find out when the payment form is actually sent, because tracking of "submit button pressed" is not sufficient as there's a validation in between that potentially stops listening to the event by default.


  • Add Javascript on the merchant's checkout flow

  • The script will listen to the 'form submit event' and execute the code - if there are no validation errors - right before the form gets submitted.

Let’s walk through the steps

Step 1:

Simply execute step number 1 'Generate a token for payment' as it is described in the Integration Guide. 

Step 2:

Build the payment form and let the shopper pay - it is at this step where the script will execute.

  • First, integrate the COPYandPAY Javascript and HTML form (where the COPYandPAY elements are attached) into your page as described in the Integration Guide.
  • Add the script within the onAfterSubmit functionality of the COPYandPAY Options & API


COPYandPAY: Payment submitted callback Collapse source
<script src="" ></script>
<script type="text/javascript">
    var cnp_Options = {
        onAfterSubmit: function(){
            // code executed right before the form gets send (at this point the validation took already place)

Step 3:

After the payment is done, proceed to step 3 as it is described in the Integration Guide.

Have more questions? Submit a request


Powered by Zendesk