{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["sub-heading"]},"type":"markdown"},"seo":{"title":"Analytics","description":"Transform your commerce with PXP's unified platform—seamless payments, real-time insights, and global growth in one powerful integration.","lang":"en-UK","siteUrl":"https://developer.pxp.io","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"analytics","__idx":0},"children":["Analytics"]},{"$$mdtype":"Tag","name":"SubHeading","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Get actionable, trackable data instantly to drive better decisions and performance."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"overview","__idx":1},"children":["Overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Analytics events are structured data objects that get automatically triggered when significant actions or states occur within the drop-in. These allow you to monitor every aspect of the payment journey."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Analytics events allow you to:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Gain transparency with native transaction tracking in PXP reports."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Optimise conversion rates and reduce drop-offs, thanks to actionable insights."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Feed real-time data into your analytics and CRM systems."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"consume-an-event","__idx":2},"children":["Consume an event"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Analytics events should be consumed in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CheckoutDropIn.initialize"]}," function."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import CheckoutDropIn from '@pxpio/web-components-sdk/src/checkoutDropIn/CheckoutDropIn';\nimport IntentType from '@pxpio/web-components-sdk/src/basePxpCheckout/types/IntentType';\nimport { BaseSubmitResult } from '@pxpio/web-components-sdk/src/checkoutDropIn/types/BaseSubmitResult';\nimport BaseSdkException from '@pxpio/web-components-sdk/src/types/sdkExceptions/BaseSdkException';\n\n// Get session data from backend\nconst sessionData = await fetch('/api/create-session', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' }\n}).then(response => response.json());\n\n// Initialise with analytics\nconst checkoutDropIn = CheckoutDropIn.initialize({\n  environment: 'test',\n  session: sessionData,\n  ownerId: 'MERCHANT-1',\n  ownerType: 'MerchantGroup',\n  transactionData: {\n    currency: 'USD',\n    amount: 99.99,\n    entryType: 'Ecom',\n    intent: {\n      card: IntentType.Authorisation,\n      paypal: IntentType.Authorisation\n    },\n    merchantTransactionId: crypto.randomUUID(),\n    merchantTransactionDate: () => new Date().toISOString()\n  },\n  onGetShopper: () => Promise.resolve({ id: 'shopper-001' }),\n  analyticsEvent: (event) => {\n    console.log('Analytics event:', event.eventName, event);\n    \n    // Send to your analytics platform\n    if (typeof gtag !== 'undefined') {\n      gtag('event', event.eventName, {\n        session_id: event.sessionId,\n        timestamp: event.timestamp,\n        ...event\n      });\n    }\n  },\n  onSuccess: async (result: BaseSubmitResult) => {\n    await verifyPaymentOnBackend(result);\n  },\n  onError: (error: BaseSdkException) => {\n    console.error('Payment failed:', error);\n  }\n});\n\n// Mount the drop-in\ncheckoutDropIn.create('checkout-drop-in-container');\n","lang":"typescript"},"children":[]}]},"headings":[{"value":"Analytics","id":"analytics","depth":1},{"value":"Overview","id":"overview","depth":2},{"value":"Consume an event","id":"consume-an-event","depth":2}],"frontmatter":{"seo":{"title":"Analytics"}},"lastModified":"2026-05-06T10:44:47.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/checkout/drop-in/web/analytics","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}