Wix Integration Steps

Instructions for installing Pushly when using Wix

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:

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

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.

Ensure you replace both instances ofSDK_KEY in the snippet with the value provided by your account manager.

<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.

Last updated