In this section we will talk about the KCO JavaScript API from an analytics point of view. We will learn how to send the events that KCO emits on every step of the purchase funnel to your analytics tool (in this case Google Analytics), in order for you to visualize the entire user journey.
We assume you are already familiar with the KCO JavaScript API, if that is not the case, please go ahead and make yourself familiar with it.
Event | Meaning |
---|---|
load | KCO iframe has been created successfully |
user_interacted | The user has interacted with the KCO iframe |
customer | Organization type (B2B or Person) was changed* |
change | Postal code, country or email was changed* |
billing_address_change | Billing address was submitted** |
shipping_address_change | Shipping address was submitted** |
shipping_option_change | The user has selected a new shipping option** |
order_total_change | We got changes on the cart from the merchant |
checkbox_change | A checkbox was checked/unchecked |
network_error | A network issue has been detected |
redirect_initiated | The user is about to be redirected to the confirmation page |
load_confirmation | The confirmation iframe has been created successfully |
*Also triggered on load so you can have the default data for those events.
**Also triggered on load if the user is pre-filled so you can have the default data for those events.
Assuming you already have GA working on your site (if not follow their instructions), we just need to listen to KCO’s events and send them to GA like this:
Let’s break this code down in pieces:
To prevent duplicating this code per event, you could create a function that gets called for each event you have subscribed and then send it to GA, something like this:
Let’s see how we can build a funnel analysis in GA. This is a example of what we could create:
Note: this is using data generated automatically by our systems which doesn’t reflect a real user interaction 100%.
For this we used the “Funnel analysis” dashboard under the “Analysis hub” and these events:
Now that you know how send KCO’s events to your analytics tools, go and have fun creating more general or detailed dashboards to understand your users better.