PayPal Insights SDK - Getting Started
Last updated: Oct 18th, 7:54pm
PayPal Insights SDK - Getting Started
To install the Insights SDK, we highly recommend that you add the base code between the opening and closing <head> tag on every page where you will be tracking website visitor actions. Most developers add it to their website’s persistent header so that it is available on all pages.
Placing the code within your <head> tags reduces the chances of browsers or third-party code blocking the Insights SDK’s execution.
The base code is configured to load asynchronously, so it will not increase the load-time of your page.
Here is the base Insights SDK code that will be required on every page to initialize the SDK and log visitor events:
When run, this code will immediately provide a global paypalInsight() function for sending PayPal analytics data about your website visitors.
Sandbox
- Inline Script
- JavaScript Modules (ESM)
- Asynchronous Module Definition (AMD)
1<!-- THE BELOW SCRIPT USES THE SANDBOX ENVIRONMENT -->2<script async src="https://www.paypalobjects.com/insights/v1/paypal-insights.sandbox.min.js"></script>3<script>4 window.paypalInsightDataLayer = window.paypalInsightDataLayer || [];5 function paypalInsight() { paypalInsightDataLayer.push(arguments); }6 // replace this with your Sandbox Client ID7 const sandboxClientID = "YOUR_CLIENT_ID";8 paypalInsight("config", sandboxClientID);9 paypalInsight("event", "js_load", { timestamp: Date.now() });10</script>
Production
- Inline Script
- JavaScript Modules (ESM)
- Asynchronous Module Definition (AMD)
1<!-- THE BELOW SCRIPT USES THE PRODUCTION ENVIRONMENT -->2<script async src="https://www.paypalobjects.com/insights/v1/paypal-insights.min.js"></script>3<script>4 window.paypalInsightDataLayer = window.paypalInsightDataLayer || [];5 function paypalInsight() { paypalInsightDataLayer.push(arguments); }6 // replace this with your Production Client ID7 const productionClientID = "YOUR_CLIENT_ID";8 paypalInsight("config", productionClientID);9 paypalInsight("event", "js_load", { timestamp: Date.now() });10</script>