APPROVE Plugin Listeners


Overview

After our plugin has loaded on any page, you may attach listeners to it. Listeners attached to the plugin will receive messages when certain actions are taken by the visitor on your site. We have added a message to the plugin that fires when an application is submitted on the page, which will allow you to track conversions.

Technical Documentation

The following code will add a listener to the plugin:

window.kwipped_approve.embedded_app.app_reference.add_listener(function(message){});

The anonymous function given as a parameter will be called by the plugin when an action is effected. Here is an example of attaching a listener that will print application submission information to the javascript console.

window.kwipped_approve.embedded_app.app_reference.add_listener(function(message){
   if(message.action=="app_submitted"){
      console.log("This is a submitted application:",message.data);
   }
 });

The properties of the message are:

  • message.action
  • message.data

The "app_submitted" action contains one more property:

  • message.route

This property may have a value of "lender_network" or "queue", and it describes where the application is going upon submission.

The message data will have the following properties:

  • message.data.customer (customer who submitted the application)
  • message.data.application (loan application information including all business information and loan totals)
  • message.data.items (items on the cart including model and price information)

Attaching the listener:

window.kwipped_approve.add_listener = setInterval(function(){
      if(window.kwipped_approve && window.kwipped_approve.embedded_app && window.kwipped_approve.embedded_app.app_reference){
         clearInterval(window.kwipped_approve.add_listener);
         //Add listener here.
      }
   },100);

Completed code example: The following code contains all of the above items.

<script>
   window.kwipped_approve.add_listener = setInterval(function(){
      if(window.kwipped_approve && window.kwipped_approve.embedded_app && window.kwipped_approve.embedded_app.app_reference){
         clearInterval(window.kwipped_approve.add_listener);
         //Add listener here.
         window.kwipped_approve.embedded_app.app_reference.add_listener(function(message){
            if(message.action=="app_submitted"){
               console.log("This is a submitted application:",message.data);
            }
         });

      }
   },100);
</script>