Requirements
A listener must be installed in the merchant’s website to relay the resulting JavaScript to the merchant so that it can be examined by the external analytics tool.
The mechanism for transferring data from the Nuvei IFrame to the parent page is postMessage.
Implementation
The following must be implemented by the merchant in coordination with Nuvei Technical Support. The merchant’s external analytics tool account begins collecting and displaying data immediately in a standard format established by Nuvei.
Instructions
- The merchant must acquire a valid account with the external analytics tool of choice.
- The merchant must establish a post messaging system in order to send information from one window to another located on a different domain.
- The specific code must be added to serialize the data and to signify the target origin of data to be sent.
- The merchant must notify Nuvei so that Nuvei can make the necessary modifications to the merchants account to enable an external analytics tool.
- The mechanism for transferring data from the Nuvei IFrame to the parent page is postMessage. To make things work, the merchant should provide the parameter to the IFrame URL, “
parent_url
“, which is the domain name of the parent page. The parameter is later used as second parameter of postMessage function.
Events and Corresponding Data Structures
Below is the list of events and corresponding data structures that are sent by postMessage and made available to the merchants:
- The first instance when some element in the IFrame is interacted with – Page load (IFrame load).
- The first instance when some element in the IFrame is interacted with – first use click.
- Whenever a user completes a field and blurs from it without inline validation errors – on blur without errors.
- Whenever a user completes a field and blurs from it and throws inline validation errors.
- Whenever a user attempts to submit their details to make a payment – on deposit click.
- Whenever a user successfully makes a deposit.
- Whenever a user attempts to submit their details to make a payment and the payment fails.
The following is a sample of code for listener as described above:
window.addEventListener("message", receiveMessage, false); function receiveMessage(event) { var origin = event.origin || event.originalEvent.origin; // For Chrome, the origin property is in the event.originalEvent object. if (origin !== "https://secure.safecharge.com") return; // ... }
Tracking Implementation Details
To facilitate the process, the merchant should provide the IFrame URL parameter, parent_url
, which is the domain name of the parent page.
The parameter is later used as a second parameter of the postMessage function.
Below is a list of events and corresponding data structures that are sent by postMessage, i.e. window.postMessage ( { action: “<action>”, label: “<label>” ,…}, parent_url):
The first instance when some element in the IFrame is interacted with – Page load (IFrame load):
{ "action":"analytics", "payload": { "action":"saw" "label":"payments iframe – " + , "cd3":"payments – " + } }
The first instance when some element in the IFrame is interacted with – first use click:
{ "action"':"analytics", "payload": { "action":"started deposit" | "started first deposit", "label":"safecharge", "cd3":"payments – " + } }
Nuvei provides “started first deposit” when a user has no defined user payment methods (afterwards known as “started deposit”).
Whenever a user completes a field and blurs from it without inline validation errors – on blur without errors:
{ "action":"analytics", "payload": { "action":"started deposit" | "started first deposit", "label":"safecharge", "cd3":"payments – " + } }
Whenever a user completes a field and blurs from it and throws inline validation errors:
{ "action":"analytics", "payload": { "action":"field error", "label": + "error – " +, "cd3" : "payments – " + } }
Whenever a user pastes (CTRL + V) a credit card number in the input field for credit card:
{ "action":"cc_pasted", "payload":{ "payment_method": } }
When the Cashier adjust its dimensions in order to fit into the IFrame:
{ "action":"resizeHeight", "payload": "700" }
When the user finishes filling in an input field:
{ "action":"analytics", "payload": { "action":"field complete", "cd3":"payments - cc_card", "label":"item_amount_1 complete" } }
When the user clicks on a suggested amount:
{ "action":"analytics", "payload": { "action":"suggested amount", "label":"suggested amount value 100", "cd3":"payments - cc_card", "selected_value": "10" } }
When the user clicks a checkbox that changes the flow of redirect payment methods, such as PayPal and Skrill.
{ "action":"analytics", "payload": { "action":"directFlowCheckboxChange", "cd3":"payments - apmgw_expresscheckout", "checkbox_state": "off", "label":"paypalDirectFlow checkbox has been changed" } }
Payments Events
Whenever a user attempts to submit their details to make a payment – on deposit click:
{ "action":"analytics", "payload": { "action": "attempted deposit"|"attempted first deposit", "label": , "deposit_amount":, "currency": , "cd3" : "payments – " + } }
Whenever a user’s deposit is pending:
{ "action":"analytics", "payload": { "action": "pending deposit"|"pending first deposit", "label": , "deposit_amount": , "currency": , "cd3" : "payments – " + } }
Whenever a user successfully makes a deposit:
{ "action":"analytics", "payload": { "action": "made deposit"|"made first deposit", "label": , "deposit_amount": , "currency": , "cd3" : "payments – " + } }
Whenever a user attempts to submit their details to make a payment and the payment fails:
{ "action":"analytics", "payload": { "action": "failed deposit"|"failed first deposit", "label": , "deposit_amount": , "currency": , "cd3" : "payments – " + } }
Registration Events
Failed Card Registration – Once a card registration is attempted but fails, Nuvei sends the following post message:
{ "payload": "failedRegistration", "label": "cc_card" }
Successful Card Registration – Once a card registration is done, Nuvei sends the following post message:
{ "payload": "successfulRegistration", "label": "cc_card", "verification_status": "New" }
Contact support in Decline recovery – Once the decline recovery lightbox is shown and the “Contact Support” option is selected, the following message is sent to the parent window:
{ "action": "contactSupport" }
Alternative Verification post message – Once a user presses an alternative verification button to start the process, the following post message is to be sent:
{ "action": "alternativeVerification", "verification_status" : "New" | "Pending" | "Verified" | "Not Verified", "method_status" : "Active" | "InActive", "label" : "", "userPaymentOptionId" : }
Withdraw Events
Successful cancel withdrawal request:
{ "payload":"successfulCancelWithdrawal", "payment_method":, "amount":, "currency": , "method_status":, "verification_status": }
Successful withdrawal request:
{ "payload":"successfulWithdrawalRequest", "payment_method":, "amount":, "currency": , "method_status":, "verification_status": }
Failed withdrawal request:
{ "payload":"failedWithdrawalRequest", "payment_method":, "amount":, "currency": , "method_status":, "verification_status": }