Web SDK instructions

To implement web push notifications and modals on your website, you must integrate the HoodEngage Web SDK.

HoodEngage’s web push notification system is supported across all major browsers, such as Chrome, Firefox, Edge, Safari, Opera, etc.

Where to find the Instructions tab

  1. In the left sidebar, go to Site Setup.
  2. Open your web configuration (e.g. DEMO).
  3. Select the Instructions tab.

Site setup overview

Site setup — Instructions tab

Changes in Site setup take effect only after you publish them, or if automatic publishing is enabled in Settings. To publish manually: use the Publish button in the upper right corner and enter a version (e.g. a version number or short description).

Publish configuration manually

Publish button and version

Publish configuration

Publish configuration or set automatic publishing in Settings

From there you can follow the two steps below.

Step 1: Install the container

This step embeds the HoodEngage SDK on your site so it can load your configuration and run modals, tags, and (when enabled) push.

  • Paste the following code on your site
    In the Instructions tab you’ll see a grey code block with a <script> tag. Copy it and paste it in the <head> (or before </body>) of every page where you want HoodEngage to run. Use the Copy button next to the code block to copy it in one click.

  • Configuration key
    Below the script you’ll see the Configuration key for this configuration. You can copy it with the Copy button next to it. You need this key if you load the SDK manually or use it in custom integrations.

Step 2: Install the service worker

The service worker is required for web push notifications. It must be installed only if you use push.

  • Download and upload sw.js to the root of your website
    Use the blue Download and upload sw.js to the root of your website button to download the service worker file. Upload the downloaded sw.js to the root of your site (e.g. so it is available at https://yourdomain.com/sw.js).

  • Or copy the service worker code
    If you prefer to manage the file yourself, use the Copy sw code button to copy the service worker code, then create a file named sw.js in the root of your website and paste the code into it.

Important:

  • Push notifications will not work unless a valid service worker is installed. Make sure sw.js is deployed to your site root and accessible.
  • Step 2 is only required if “Enable Push Notifications” is turned on in the Push tab of your configuration. If you use only modals, tags, or analytics, you can skip this step.

The HoodEngage SDK file must be publicly accessible and should be located at the top-level root of your site. The HoodEngage SDK will search for the file at https://ocamba.com/sw.js