Can I place Push files in custom folder?

By default we ask website owners to copy Push files to their main (root) folder, so that are available from:

https://www.website.com/manifest.json
https://www.website.com/logo_192_by_192.png
https://www.website.com/sw-mt.js

How to place these files in custom folder?

For example, if you would like to place files in https://www.website.com/media/ folder or any different subfolder that is possible as well. In this case then you need to follow these instructions:

1. Upload files to server.

Copy the 3 files to your /media/ folder (or change /media/ to the folder you would like to use). So that they would be available from:
 
https://www.website.com/media/manifest.json
https://www.website.com/media/logo_192_by_192.png
https://www.website.com/media/sw-mt.js

2. Update the MaxTraffic tracking code.

If your website ID = 1234, then your tracking code by default would look like:
<script>
  window.mt=window.mt||function(){(mt.q=mt.q||[]).push(arguments)};mt.l=+new Date;
  mt('create', 1234);
</script>
<script async src='//cdn.mxapis.com/mt.js'></script>

Please replace it with following tracking code:

<script>
  window.mt=window.mt||function(){(mt.q=mt.q||[]).push(arguments)};mt.l=+new Date;
  mt('create', 1234, {
        worker: '/media/sw-mt.js',
        manifest: '/media/manifest.json',
});
</script>
<script async src='//cdn.mxapis.com/mt.js'></script>

Don't forget to adjust the tracking code to your website:

  • Replace 1234 with your website ID
  • Replace /media/ with the folder that you will use

3. Add custom header

Ask your IT team to make sure, that service worker file (sw-mt.js) has this header:
 
Service-Worker-Allowed: '/' 
 
If that is not the case - then your website server software (probably Apache or nginx) needs to be configured so that when visitors browser requests this https://www.website.com/media/sw-mt.js file, then this specific header is used.