# Integrate Webpush Notifications

## Steps

1. **Add Your Website**
   * Navigate to the *Settings* section in the Marketing Engine
   * Go to *Integrations, Website,* and *Add a New Website*
   * Add required fields and hit *Submit*
2. **Request Web Push Activation**
   * Reach out to the Marketing Engine support team at <me-support@satisfilabs.com> to enable web push notifications for your website.
3. **Receive Website Credentials**
   * Once web push is enabled, the support team will provide you with a unique website ID and domain.
4. **Update Your Website**
   * Use the provided website ID and domain to add the required scripts to the `<head>` section of your website’s `index.html` file.

```
<!-- Start FTreal -->
<script type="application/javascript" async>
    (function () {
        let a = document.createElement("script");
        let m = document.getElementsByTagName("script")[0];
        a.async = true;
        a.src = "https://g1-tracker.factoreal.com/ftreal.min.js";
        a.onload = function () {
            let ftreal = (window.ftreal = window.ftreal || {});
            ftreal.init("{Website_id}", true);
        };
        m.parentNode?.insertBefore(a, m);
    })();
</script>
<!-- End FTreal -->
<!-- Start WebPush -->
<script type="text/javascript" async>
    var _at = {};
    var u = "https://storage.googleapis.com/factoreal-webpush-global/";
    _at.domain = '{Domain}';
    // Sample: _at.domain = 'combifam.com' (for regular websites) or 
    // 'combifam.myshopify.com' (for Shopify website)
    _at.idSite = '{Website_id}';
    // Sample: 514cc670-a384-11ed-87ce-41eeaf703333
    (function () {
        var d = document,
            g = d.createElement("script"),
            s = d.getElementsByTagName("script")[0];
        g.type = "text/javascript";
        g.async = true;
        g.src = u + "fsw.min.js";
        s.parentNode.insertBefore(g, s);
    })();
</script>
<!-- End WebPush -->
```

5. Add a new file named \`sw-factoreal.js\` to the same folder as \`index.html\` with the content  below:

{% code overflow="wrap" %}

```
importScripts("https://storage.googleapis.com/factoreal-webpush-global/sw-factoreal.js");
```

{% endcode %}

6. To send webpush to contacts, you need to pass the user’s email/phone number when they log in to your site. This will help create audiences and send customized push notifications.

```
<script>
    function oauthCallback(user) {
        // handle login...
        if (user.email) {
            ftreal?.setUserId(user.email);
        } else if (user.phone) {
            // phone number should be in E.164 format
            // https://www.twilio.com/docs/glossary/what-e164
            ftreal?.setUserId(user.phone);
        }
    }
</script>
```


---

# 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://docs.satisfilabs.com/resource-center/marketing-engine/settings-and-integrations/settings/integrate-webpush-notifications.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.
