Installation
The Web SDK tracks customer behavior on non-Shopify websites. It handles page views automatically and provides methods for identifying users and tracking custom events.
Script Tag
Add this to your website's <head> section:
<script
src="https://cdn.postscript.io/v1/sunrise.min.js?propertyId=YOUR_PROPERTY_ID"
async
></script>Replace YOUR_PROPERTY_ID with your property ID from the Postscript dashboard (Settings → API Keys).
The SDK initializes automatically and begins tracking page views.
Manual Initialization
If you need to control initialization (e.g., for consent management), load the SDK without the propertyId query parameter and initialize manually:
<script>
window.sunrise = window.sunrise || [];
sunrise.push(['init', {
propertyId: 'YOUR_PROPERTY_ID',
consentMode: 'pending' // optional — queues events until consent is granted
}]);
</script>
<script src="https://cdn.postscript.io/v1/sunrise.min.js" async></script>See Consent Management for details on consent modes.
Debugging
Enable debug mode to see SDK activity in your browser console:
// Enable debug logging
sunrise.push(['debug', true]);
// Or persist across page loads via localStorage
localStorage.setItem('_sr_debug', 'true');Debug mode logs all tracked events, identify calls, and network requests to the browser console.