Detecting ad blocker

the Unity Ads plugin does some ad blocker detection (for ad server IP being redirected to localhost), and logs it, but it doesn’t appear to make that info available within Unity.

I would like to run that check in my script and respond appropriately, so…

  1. Is there a plugin function I haven’t found for testing for ad blockers?

  2. If not, is there a consistent Ad Server URL I can test against, or does it change over time/across regions?

Thanks!

-Scott

Haven’t heard about such plugin. If you can describe the use case in more detail, we can consider if it’s a feature we should include.

If you look at traffic from your device, you’ll see that SDK connects to https://adserver.unityads.unity3d.com/, so you could try to connect to that. You’ll get 404 response, even if you can connect, but I believe you would simply get some sort of “unable to connect” if there is an adblocker installed. Please note that this is undocumented, and we might change the urls over time.

But again, you are welcome to describe the use case, then we’ll see if we should make support for this.

/Rasmus

1 Like

Thanks Rasmus!

The use case would be for any app that uses reward ads; if I detect an ad-blocker, I would (one time) show the user a message of all the amazingly cool stuff they’re missing out on, and suggest that they add “*.unityads.unity3d.com” to their whitelist so they can partake in the awesomeness.

It seems like ad-blockers are becoming more and more common on phones, so I think providing the info that a user would need to enable Unity ads would be beneficial.

-Scott

Actually thinking about it, not sure we can detect adblockers as such. We can detect if device is rooted, but an adblocker probably for us just looks like we cannot connect to the backend, which could happens for several reasons.

So your check should probably be something like “if internet connection available but ads hasn’t been initialized after some time”, show the message to user. Search for “unity internet connection check mobile” to find a couple of suggestions for how to verify internet connectivity in a Unity project.

/Rasmus

1 Like

It should be trivial to detect if an ad blocker is being used if a user uses unity analytics (From the server end), as a connection to analytics would go through while an advertisement would 404 or be rejected instantly on the device.

From the user end, if a ping to unity3d.com (or a range of hosts that just don’t go down, like Google.com) resolves, while a connection to .unityads.unity3d.com is blocked, it could be inferred that .unityads.unity3d.com is either down or being blocked.