# Detect Ad-blocked Pages

The JavaScript SDK lets you send a page view containing the relevant markers that determine whether a page is ad-blocked. You can analyze this data to find what percentage of your website's pages are affected by ad blockers.

## How the feature works

The JavaScript SDK makes a `HEAD` request to the [source config endpoint]({{< ref "sources/event-streams/sdks/rudderstack-javascript-sdk/load-js-sdk.md#loading-options" >}}) (by default, it is `https://api.rudderstack.com/sourceConfig`) with a query parameter that ad blockers typically block (`?view=ad`). It then determines if the ad blockers are active depending on whether the request succeeds or fails.

Thus, it is a good way to identify how many user sessions have active ad blockers.

{{< info >}}
This feature **will not work** if the JavaScript SDK itself is unable to load successfully due to ad blockers. 

Hence, RudderStack recommends using this feature if you are serving the JavaScript SDK over a [custom domain]({{< ref "user-guides/how-to-guides/custom-domains/" >}}).
{{< /info >}}

## Send ad-blocked page view

To send an ad-blocked page view, load the JavaScript SDK as shown:

```javascript
rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL, {
    sendAdblockPage: true,
    sendAdblockPageOptions: {
        integrations: {
            All: false,
            Amplitude: true
        }
    },
    ...
});
```

Replace the {{< glossary_tooltip "write-key" >}} and {{< glossary_tooltip "data-plane-url" >}} in the above snippet with their actual values.

The properties included in the above snippet are explained below:

| Property | Description |
| :----| :----| 
| `sendAdblockPage` | Enables the JavaScript SDK to send an additional `page` event along with the actual event whenever you make the `page` call and the SDK detects that ad blockers are active on that web page. |
| `sendAdblockPageOptions` | The JavaScript SDK makes an implicit `page` call with the specified options. |

With `sendAdblockPageOptions` (containing the [`IntegrationOpts`]({{< ref "sources/event-streams/sdks/rudderstack-javascript-sdk/load-js-sdk.md#integrationopts" >}}) object), you can specify the destinations to which you want to forward this `page` call. See [Filtering selective destinations]({{< ref "sources/event-streams/sdks/rudderstack-javascript-sdk/filtering.md" >}}) for more information.

The implicit `page` call semantics are shown:

```javascript
rudderanalytics.page(
    "RudderJS-Initiated",
    "ad-block page request", {
        path: "/ad-blocked"
    },
    sendAdblockPageOptions
);
```
