Analytics

Last updated: Nov 3rd, 8:09am

<span>Pay Later messaging analytics</span>

Pay Later messaging analytics

When you integrate Pay Later messaging, you also can integrate your analytics platform and add events that are related to Pay Later offers and messaging.

The JavaScript SDK v6 accepts optional callback function properties.

Events

The following table lists functions that the SDK calls immediately. Your analytics platform can use these events for tracking.

Event Description
onRender Invoked after each message renders into the DOM
onClick Invoked after a user selects the message
onApply Invoked after a user selects the Apply button or link in the pop-up modal

The following code sample calls the paypal.Messages function to create a message object with optional properties for the onRender, onClick, and onApply events. The functions in this example add an entry to the console log when one of these events occurs.

You also can use inline HTML attributes to add event hooks.

    1<!DOCTYPE html>
    2
    3<head>
    4 <meta name="viewport" content="width=device-width, initial-scale=1">
    5 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    6 <script src="https://www.paypal.com/sdk/js?client-id=CLIENT_ID&components=messages">
    7 </script>
    8</head>
    9
    10<body>
    11 <div class="pp-message"></div>
    12 <script>
    13 paypal.Messages({
    14 amount: 500,
    15 pageType: 'product-details',
    16 style: {
    17 layout: 'text',
    18 logo: {
    19 type: 'primary',
    20 position: 'top'
    21 }
    22 },
    23 onRender: () => {
    24 console.log('render')
    25 },
    26 onClick: () => {
    27 console.log('click')
    28 },
    29 onApply: () => {
    30 console.log('apply')
    31 }
    32 })
    33 .render('.pp-message');
    34 </script>
    35</body>

    Logging

    The following sample response shows an event message in the console log.

    For more information about logging events, see your analytics platform's documentation about logging custom events. Add the necessary code to the function body of the event hook for the messages configuration object.

      1<div
      2 data-pp-message
      3 data-pp-onrender="console.log('Callback called on render')"
      4 data-pp-onclick="console.log('Callback called on click')"
      5 data-pp-onapply="console.log('Callback called on apply')"
      6></div>