Anstrex Native Ad Intelligence Tool
Effortlessly generate, customize, and launch top-performing native ads using powerful AI-driven intelligence from Anstrex—saving you time & money

[script] Detect if your ad is iframed in pop network

CloudTalk

meannn

Grand Guru
Joined
Feb 28, 2019
Messages
361
So some bad players (mostly publishers) use hidden iframes on the page like 1x1px which users don't even see. To detect that, just put this code in your ad page and now you will see who are the bad players. You just need to be at least beginner in coding. This code also gets the publisher ids.

Lets say your ad is mysite.com/ad.php?zoneid={zoneid}
(zoneid can change from different pop networks, just change to their type)

In your ad page, add this;

<script> (function () { var inFrame = true; try { inFrame = (window.self !== window.top); } catch (e) { /* cross-origin: still iframed */ } if (!inFrame) return; // Simple beacon (no CORS issues). Add whatever query params you want. new Image().src = 'https://mysite.com/badplaterdetect.php?id=<?php echo $_REQUEST["zoneid"] ?>' + '&u=' + encodeURIComponent(location.href) + '&r=' + encodeURIComponent(document.referrer || '') + '&t=' + Date.now(); // cache-buster })(); </script>

And in your badplayerdetect.php, add this so it creates publisher ids automatically add ids to your server directory. So at the end of the day you will see bad player ids and block them on the pop network.

<? $badid = $_REQUEST["id"]; file_put_contents($badid.txt', "Bad guy detected\n"); ?>
 
To view the premium content in our affiliate marketing forum (including this awesome thread), you must first register and upgrade your account. Register today and become a part of our amazing community!
Top