Website SDK HTTPS Installation

Gravitec SDK Installation for Chrome websites (desktop + mobile)


W3C Web Push Notifications are currently only supported by Chrome 42+

  • Includes Chrome for Windows, Mac OS X, Linux, Chrome OS, and Android. Chrome for iOS is not yet supported.


If some of your pages are served via HTTP instead of HTTPS, then you will need to follow our HTTP Installation Guide instead.

If possible, we encourage you to migrate all your pages to HTTPS first, and then continue using this guide.


1. Download the SDK

1.1 Download the latest version of Gravitec Chrome Web SDK after the registration of your site in the Gravitec Dashboard.

1.2 Copy push-worker.js and manifest.json from gravitec_sdk_ directory and paste it into the top-level directory (root folder) of your site.


2. Include Required Files

2.1 Link and manifest.json to each page of your website by adding some code between <head> and </head> tags. Update APP_KEY with your Gravitec AppId. Most likely, you will have to do it just once in the file, which helps to generate a layout of the site. The resulting HTML should look like this:

 <script src="" async></script>

Now user will see a window asking for permission to receive notifications from your site immediately after opening the page:


3. Customize Gravitec (Optional)

3.1 Your custom button or event.

Call Gravitec.push(["init"]) from a javascript file that is included in every page. Create or use your button and update YOUR_CUSTOM_BUTTON_ID with your button id.

The user will see a window asking for permission to receive notifications from your site immediately after clicking on the button.

You can create your own logic and call registerPush() method.


You must keep all the SDK files together., push-worker.js and manifest.json must be placed in the root directory of your site.

Link to must be added between <head> and </head> tags for every page on your website. Linking files this way allows us to be sure that: - any page can subscribe to notifications - any page can be opened from a notification (if set) - changes to the Google Registration id can be updated - session count can be accurately calculated.

That's It!

That’s it for now - the setup is complete. See our Web SDK API for more functions.

var Gravitec = Gravitec || [];
Gravitec.push(["init", {"autoRegister":false}]);
window.onload = function(){
 //Replace YOUR_CUSTOM_BUTTON_ID with your button id
 document.getElementById("YOUR_CUSTOM_BUTTON_ID").onclick = registerPush;
 function registerPush() {
  Gravitec.push(["registerUserForPush", function(success){
   if (success) {
    //your custom action