# Wix Integration Steps

If your website utilizes Wix follow these steps for implementation

## Step 1: Install the Service Worker

First, enable Wix Dev Mode and add a file to expose the Service Worker:

1. Open your Wix admin dashboard
2. Click the "Edit Site" button in the top right of the dashboard
3. Click the "Dev Mode" tab at the top of the site and click the “Turn On Dev Mode” button
4. Click the “Public & Backend” `{}` sidebar menu option
5. In the "Backend" section click “Add web module” and enter the filename: `http-functions.js`
6. Replace the entire contents of the `http-functions.js` file with the following code:

```javascript
import { ok } from 'wix-http-functions';

export function get_ServiceWorker(request) {
  let options = {
    "headers": {
      "Content-Type": "application/javascript",
      "Service-Worker-Allowed": "/"
    },
    "body": "importScripts('https://cdn.p-n.io/pushly-sw.min.js' + (self.location || {}).search || '');"
  };
  
  return ok(options);
}
```

After clicking the “Publish” button make sure the service worker is accessible at your site. For example: `https://www.mysite.com/_functions/ServiceWorker`

<figure><img src="/files/KSNZVHNrw0ncSOH8oHCd" alt=""><figcaption></figcaption></figure>

## Step 2: Add the Integration Code Snippet

1. Navigate back to the main Wix Dashboard
2. Click the "Settings" sidebar link and then "Custom code" near the bottom of the page
3. Click the “Add Custom Code” button and place the following code in the code text area. Leave the “All Pages” radio button selected.

{% hint style="warning" %}
Ensure you replace **both** instances of`SDK_KEY` in the snippet with the value provided by your account manager.
{% endhint %}

```
<script src="https://cdn.p-n.io/pushly-sdk.min.js?domain_key=SDK_KEY" async></script>
<script>
  window.PushlySDK = window.PushlySDK || [];
  function pushly() { window.PushlySDK.push(arguments) }
  pushly('load', {
    domainKey: 'SDK_KEY',
    sw: '/_functions/ServiceWorker',
  });
</script>
```

Save the snippet to complete the integration steps.

<figure><img src="/files/41ae30OE0RwZcDR8qbEj" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.pushly.com/integration/web-push/wix-integration-steps.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
