Unlock the full potential of our feature and take your skills to the next level! Dive into our Training Center and discover exclusive Best Practice resources that will elevate your implementation strategy. With expert tips and insider knowledge, you'll become a master in no time. Access the links below to learn more and gain a competitive edge.
Ready to get started? Our Training Center is just a click away: here.
*For more information about our Training center, please visit the article here.
How Piano detects ad blockers
Piano detects ad blockers by executing a call to a mock ad network and detecting whether or not that call is blocked. If it is blocked, we set cookie values to indicate presence of an ad blocker. We then track every page view to detect whether that browser's ad blocker has been turned off.
As a secondary measure, we employ additional ad block detection scripts that automatically monitor our clients' sites to verify that the detection logic is working properly. If the ad blocker community were to thwart our detection methods, this monitoring would allow us to immediately identify the issue and deploy a fix to our detection script.
Installing Piano's ad block detection script
Simply add this JavaScript directly to all pages of your site:
<script>
document.cookie = "__adblocker=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
var setNptTechAdblockerCookie = function(adblocker) {
var d = new Date();
d.setTime(d.getTime() + 60 * 5 * 1000);
document.cookie = "__adblocker=" + (adblocker ? "true" : "false") + "; expires=" + d.toUTCString() + "; path=/";
};
var script = document.createElement("script");
script.setAttribute("async", true);
script.setAttribute("src", "//www.npttech.com/advertising.js");
script.setAttribute("onerror", "setNptTechAdblockerCookie(true);");
document.getElementsByTagName("head")[0].appendChild(script);
</script>
To ensure maximum effectiveness, we strongly recommend adding this detection script as the first element in your <head> tags, while the rest of Piano's JavaScript should fall within the body. We also recommend that you add this script inline. If you instead use a tag manager to load the script, detection may be less accurate as a result.
Note that the advertising.js needs to be loaded prior to the Composer execution (i.e. any other Piano scripts), so the adblocker cookie is created before any Experience is executed.
Using third-party ad block detection
You aren't required to use our script; Composer works seamlessly with any third-party ad block detection method. You simply need to set our cookie values appropriately using the information below.
When a user has an ad blocker turned on, Piano's script registers an onerror callback that sets the __adblocker cookie to true. If no ad blocker is detected, an onload callback sets the __adblocker cookie to false. Piano then reads the state of the __adblocker cookie so you can target ad blockers (or non-ad blockers) using the User Segmentation card in Composer.
The rules for how Piano treats the cookie are:
-
If the
__adblockercookie doesn't exist, the ad blocker state will be recorded asnot detected. -
If the
__adblockercookie is set and the boolean istrueor the string is "true" the state will beenabled. -
If the
__adblockercookie is empty, the booleanfalse, or any string other than "true", the state will bedisabled.
How Piano handles script blockers
We are in a constant cycle of working with ad-block and script blocking organizations to ensure that they keep scripts from tinypass.com and piano.io domains out of their list of blocked scripts. In most cases, this may take anywhere from a few days to a few weeks to organize, however, we are not always successful in getting them to remove our domain and some have cached lists and individual users may also have our scripts blocked.
Blocking our scripts completely causes a bigger issue on the site of our clients and as such one option is for the client to have some code on their site validating that the Piano script is loaded correctly by checking for the existence of the tp object. If the tp object is not available, then you would be able to assume that the Piano script is not working for some reason. From there you would be able to make some assumptions of what experience to provide to the user. Whether it be some instructions or suggestions of how to turn off the content blockers or to stop showing different content. An example of how to check would be watching for the init callback to fire when the Piano script initializes. It is not 100% foolproof but should help to recognize issues for users.
Below is a code snippet that could be used to replace the standard integration script and will return one of either two options tinypass.min.js is loaded and initialized from the Piano domains or it was not loaded. This example logs this information into the console:
<!-- initialize settings -->
<script type="text/javascript">
tp = window.tp || [];
tp.push(["setAid", '<AID>']);
// Use https://sandbox.piano.io/api/v3 for sandbox
tp.push(["setEndpoint", 'https://buy.piano.io/api/v3']);
// Set to false unless instructed otherwise by a Piano representative
tp.push(["setUseTinypassAccounts", false]);
// Set to "true" only if using Piano id - otherwise should be set as per the integration script
tp.push(["setUsePianoIdUserProvider", true]);
</script>
<!-- Load tinypass.min.js Execute composer -->
<script>
((src) => {
return new Promise(function(t,e){let n=document.createElement("script");
n.src=src,n.type="text/javascript",n.async=!0,n.onerror=(()=>e()),n.onload=(()=>{"function"==typeof window.___tp?(tp=window.tp||[],tp.push(["init",function(){t()}])):e()});
let o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(n,o)});
})('//cdn.piano.io/api/tinypass.min.js').then(
() => {
// tinypass.min.js is loaded and initialized. Additional actions could be performed
// Execute composer
window.tp.experience.init();
console.log('Piano Script was executed');
},
() => {
// The tinypass.min.js script was blocked due to content filter
// User should be presented with a suggestion to disable filter.
console.log('Piano Script was blocked');
}
)
</script>
Please let us know of specific blocking scripts that are causing problems for your users and we will endeavor to have them remove Piano from their blacklists.
List of known ad blockers and trackers
|
SOFTWARE |
TYPE |
DETECTED VIA COMPOSER |
EFFECT ON PIANO SCRIPTS |
|---|---|---|---|
|
Adblock |
Ad blocker |
Yes |
None |
|
Adblock Plus |
Ad blocker |
Yes |
None |
|
Easylist Filter |
Ad blocker |
Yes |
Blocks cx.js scripts |
|
Ghostery |
Content Filter |
No |
Blocks Piano scripts |
|
uBlock |
Ad blocker |
Yes |
None |
|
uBlock Origin |
Content Filter |
No* |
Blocks Piano scripts |
|
Adguard |
Content Filter |
No |
Blocks the Adblock detection script |
|
Disconnect v20.1 |
Content Filter |
No |
Blocks cx.js scripts |
|
Adblocker Ultimate |
Ad blocker |
Yes |
Blocks cx.js scripts** |
|
Privacy Badger |
Content Filter |
No |
Blocks cx.js scripts |
|
Pi-hole.net |
Content Filter |
No |
Prevents Piano scripts from running and templates/modals therefore do not work. |
|
NordVPN |
Content Filter |
No |
Blocks Piano scripts |
|
Fanboy-Adblock |
Ad blocker |
Yes |
None |
|
Malwarebytes |
Content Filter |
No |
Blocks cx.js scripts |
|
Stands Fair AdBlocker |
Ad blocker |
Yes |
None |
|
Crystal Ad block |
Ad blocker |
No |
Prevents Piano scripts from running and templates/modals therefore do not work. |
|
Poper Blocker |
Ad blocker |
No |
None |
|
DuckDuckGo |
Browser |
No |
Blocks cx.js scripts |
|
Brave Shields |
Browser |
No |
Blocks cx.js scripts |
|
Adblock 2020 (for Edge) |
Ad blocker |
No |
Blocks cx.js scripts and the Adblock detection script |
|
Firefox ("Strict" enhanced tracking protection mode) |
Content Filter |
No |
Blocks Piano scripts |
*Detected when the nptech script is defined inline on the page.
**Blocks the Adblock detection script and Cxense scripts. However, due to the Adblock script fallback, the status is defined correctly, so the Adblock detection works correctly.