Docs / 개발자

이 문서는 영어로 표시됩니다.

Service worker

Web push requires a service worker that controls the page origin. A browser will not accept a worker served from another domain, so this is the one EngageNudge file that lives on your server. EngageNudge expects /en-sw.js with a root scope (/).

The file itself is a stub. The push logic behind it is loaded from EngageNudge, so worker fixes reach your site the same way SDK fixes do.

Standalone

Download en-sw.js from the dashboard Integrations tab and place it at the site root so it is reachable as https://your-origin/en-sw.js. It contains one line:

js
importScripts("https://engagenudge.com/sdk/v1/en-sw.js");

Re-save permalinks on WordPress if the worker 404s. Purge CDN cache after you deploy. You never need to replace this file again.

The WordPress plugin serves its own bundled worker at /en-sw.js and /engagenudge-sw.js via rewrite rules; it updates with the plugin instead.

Merge with an existing worker

If you already have a root worker (PWA, another push vendor), do not replace it blindly.

Add this at the top of your existing worker:

js
importScripts("https://engagenudge.com/sdk/v1/en-sw.js");

The plugin’s merge mode does not overwrite your file. You add that line yourself.

GTM

Google Tag Manager cannot register a same-origin worker. Host /en-sw.js yourself even when the SDK is injected by GTM.

Older installs

A worker file with the full EngageNudge bundle inlined keeps working exactly as before. Swap it for the stub whenever you want worker fixes without a re-upload.

Checks

Install Doctor should report the worker reachable, in the right scope, and controlling the page. See Troubleshooting.