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 page views are affected by adblockers.
Sending an ad-blocked page view
To send an ad-blocked page view, load the JavaScript SDK as shown:
rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL, { sendAdblockPage: true, sendAdblockPageOptions: { integrations: { All: false, Amplitude: true } }});
WRITE_KEY
and DATA_PLANE_URL
in the above snippet with the actual values.The properties included in the above snippet are explained below:
sendAdblockPage
: Enables the JavaScript SDK to make a call to load the Google AdSense library. If RudderStack fails to load this library, it concludes that an adblocker is enabled on the page.
sendAdblockPageOptions
: If thesendAdblockPage
property is set totrue
, the JavaScript SDK makes an implicitpage
call about the ad-blocked pages.
With sendAdblockPageOptions
(containing the IntegrationOpts
object), you can specify the destinations to which you want to forward this page
call.
The implicit page
call semantics is shown below:
rudderanalytics.page( "RudderJS-Initiated", "ad-block page request", { path: "/ad-blocked", title: "error in script loading:: src:: http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js id:: ad-block" }, sendAdblockPageOptions);
Contact us
For more information on the topics covered on this page, email us or start a conversation in our Slack community.