Requirements
D·engage Web SDK provides an interface that handles device subscriptions and web push notifications. Optionally, it also provides event tracking functionality for your website.
To use the Web SDK, create an application and set up push notification configuration in the D·engage platform, then add the Service Worker File and the Injection Script to your website.

Applications

Website

Website Application

Push Notifications - Enabled

If you enable the “Show Permission Prompt on page load” option, the permission prompt will be shown automatically without awaiting a trigger.
Once you have created the Application in the D·engage platform, your website integration details will appear as shown below.

Web Application Details
Download the Service Worker file and add it to your website’s root folder. Only one Service Worker file should be used for generating a Web Push token. If another Service Worker is already generating a token, it must be removed first before adding the D·engage Service Worker file.
Insert the provided code snippet into your website’s HTML code. If you enable the “Show Permission Prompt on page load” option, the web push integration will work automatically. Otherwise, you can manually trigger the notification prompt using the SDK functions.
These certificates are required to send web push notifications to Safari users on macOS.
Requirements

Website Push ID
If you do not already have a Website Push ID, create one using the steps below:

Certificate Signing Request
You will need a CSR file to create the push certificate.
On macOS (Keychain Access)
.certSigningRequest file.
Create the Safari Web Push Certificate
D.engage website application will typically require a .p12 certificate.
.p12 file.Upload the .p12 certificate and password to your D·engage Website Application to activate Safari push notifications. Push Notification > Safari

Push Notification > Safari
By creating a Website Push ID, generating a CSR, creating a certificate, and exporting it as .p12, you can successfully enable Safari Web Push on macOS.
Once you insert the Injection Script into your main HTML file, the SDK’s core functionality starts automatically. This includes displaying Web Push Notification permission prompts and tracking notification subscriptions. Therefore, the initialization function is essential.
If you have enabled the “Show Permission Prompt on Page Load” option in the D·engage platform, you don’t need to implement this step. Otherwise, to trigger the prompt manually, use the showNativePrompt or showCustomPrompt functions.
The showNativePrompt function immediately displays the browser’s native permission prompt.
The showCustomPrompt function displays the custom prompt type you selected in your application settings. Once the user accepts, the native browser prompt will be shown.
If you have a button or banner for requesting notification permission, you can call showNativePrompt in its click handler.
You can use the getNotificationPermission function to retrieve the user’s current notification permission status. This function returns a string value that can be 'granted', 'denied', 'ignored', or 'default'.
You can use the getToken function to retrieve the current Web Push token. This function returns nullif the Web Push permission has not been granted.
You can use the isPushNotificationsSupported function to check whether the browser supports Web Push Notifications. This function returns true if Web Push is supported.
When a user logs in, you obtain their user information, including a contact_key. You can set this contact_key to associate the user with their browser. There are two functions for setting and retrieving the contact_key.
If the user is logged in, set their user ID. This is important for identifying users. You can safely call this function on every page — it will not send unnecessary events.
To retrieve the current user information from the SDK, use the following function:
You can also get the current device ID from the SDK using the getDeviceId function:
For accurate tracking, the country information of web devices should be set on your website. You can use the following functions to set and retrieve this information:
Set the user's country:
Retrieve the user's country:
You can use this function when the user does not allow cookies on the site.
Set the tracking permission: The parameter for setTrackingPermission should be a boolean (true or false).
Get the tracking permission:
You can use these functions to store the user's cart data.
Use the setCart function to send the current cart data to the SDK. This function automatically calculates and adds additional properties to each cart item. These calculated fields include: Effective_price, line_total, discounted_line_total, effective_line_total
The function can be called using either the setCart name or its ec: prefixed version ec:setCart.
You can use this function to control the SDK’s log output in the browser console. This is useful for debugging or monitoring SDK activity.
Use the setLogLevel function to specify the desired log level.
Available levels are: none – Disable all SDK logs. info – Show informational and status messages. warn – Show warnings and errors. error – Show only error messages.
Log messages will be displayed in the browser’s developer console based on the selected level.
You can use this function to download the SDK logs as a JSON file.
Use the exportLogs function to download all available SDK logs in JSON format. The file will be saved to the user’s computer through the browser’s download mechanism.
Please refer to Custom Event Setup.