# 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="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2FNk5uU2nVh1DdCd4YjhMn%2FScreenshot%202023-10-02%20at%209.59.31%20AM.png?alt=media&#x26;token=16438b11-c8db-4889-8bd0-60a3c5a1a7a1" 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="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2FiH0w1ahfnlePhHVucgs7%2FScreenshot%202023-10-02%20at%2010.01.51%20AM.png?alt=media&#x26;token=5e7bb697-a85a-4084-ab49-dd5513849a8b" alt=""><figcaption></figcaption></figure>
