Closed oangelo closed 7 years ago
Hi. I can't seem to reproduce this problem. And we also have the plugin in a lot of our own aps and it works fine. Does analytics show any crashes or exceptions for your app?
I am using this code:
var adReady = false;
var adTimer = true;
var adPluginLoaded = false;
var adBannerShown = false;
var lastCardName = 'none';
function initAd(){
if ( window.plugins && window.plugins.AdMob ) {
adPluginLoaded = true;
var ad_units = {
ios : {
banner: 'secret', //PUT ADMOB ADCODE HERE
interstitial: 'secret' //PUT ADMOB ADCODE HERE
},
android : {
banner: 'secret', //PUT ADMOB ADCODE HERE
interstitial: 'secret' //PUT ADMOB ADCODE HERE
}
};
var admobid = ( /(android)/i.test(navigator.userAgent) ) ? ad_units.android : ad_units.ios;
window.plugins.AdMob.setOptions( {
publisherId: admobid.banner,
interstitialAdId: admobid.interstitial,
adSize: window.plugins.AdMob.AD_SIZE.LARGE_BANNER, //use SMART_BANNER, BANNER, IAB_MRECT, IAB_BANNER, IAB_LEADERBOARD
bannerAtTop: false, // set to true, to put banner at top
overlap: false, // banner will overlap webview
offsetTopBar: false, // set to true to avoid ios7 status bar overlap
isTesting: false, // receiving test ad
autoShow: false // auto show interstitial ad when loaded
});
registerAdEvents();
window.plugins.AdMob.createInterstitialView(); //get the interstitials ready to be shown
window.plugins.AdMob.requestInterstitialAd();
} else {
//alert( 'admob plugin not ready' );
}
}
//functions to allow you to know when ads are shown, etc.
function registerAdEvents() {
document.addEventListener('onReceiveAd', function(){});
document.addEventListener('onFailedToReceiveAd', function(data){
setTimeout( function() {
window.plugins.AdMob.requestInterstitialAd();
}, 1000*30);
window.analytics.trackEvent('Ad', 'Interstetial', "Error");
});
document.addEventListener('onPresentAd', function(){});
document.addEventListener('onDismissAd', function(){ });
document.addEventListener('onLeaveToAd', function(){ });
document.addEventListener('onReceiveInterstitialAd', function(){
adReady = true;
window.analytics.trackEvent('Ad', 'Interstetial', "Received");
});
document.addEventListener('onPresentInterstitialAd', function(){ });
document.addEventListener('onDismissInterstitialAd', function(){
window.plugins.AdMob.createInterstitialView(); //REMOVE THESE 2 LINES IF USING AUTOSHOW
window.plugins.AdMob.requestInterstitialAd(); //get the next one ready only after the current one is closed
adReady = false;
window.analytics.trackEvent('Ad', 'Interstetial', "Closed");
});
}
//display the banner
function showBannerFunc(){
if (adPluginLoaded){
window.plugins.AdMob.createBannerView();
adBannerShown = true;
}
}
//display the interstitial
function showInterstitialFunc(){
if (adPluginLoaded){
if (adReady && adTimer){
setTimeout( function() {
adTimer = true;
}, 1000*60);
adTimer = false;
window.plugins.AdMob.showInterstitialAd();
window.analytics.trackEvent('Ad', 'Interstetial', "Show");
}
}
}
function closeBannerFunc(){
if (adBannerShown && adPluginLoaded){
window.plugins.AdMob.destroyBannerView();
adBannerShown = false;
}
}
Analytics tells me this:
And admob says I had 1169 requests and just 340 impressions, with a fill rate of 100%. I can't spot any mistakes in my code, but something is very wrong... Any ideas?
Because is certain countries Admob probably doesn't have such a big range of ads to show, and this line
setTimeout( function() { window.plugins.AdMob.requestInterstitialAd(); }, 1000*30);
Pings their server quite often if they fail to deliver ads. And then maybe they just block ad serving.
What I would suggest, instead of looking at how many failed ad requests you get, is to check how many times do you want to show an ad and cannot as a percentage of how many times you need to show.
I thought about that, that Google might not have ads to serve. But, AdMob say that my fill rate is 100%! Might be because of slow internet connection, the user can be having trouble dowloading the add, since I am in Brazil and the internet sucks. But I don't think this is the case, because using another plugin I was having a more plausible relation between requests and impressions, more than 50% of the requests turned in to impressions. Could not be the version of AdMob sdk or something like this?
Admob automatically downloads the latest sdk onto each phone as a part of the play services. The library you embed is not the one that gets used. I would say it has to do with the internet connection as you say, because in US and Europe this definitely is not a problem. Be careful not to make too many requests to the Admob servers also, this could also cause problems.
I am using this plugin for some time, I was using another admob plugin before. But I am noticing a very strange behavior, my impressions are ridiculously low for interstitials now. I am having more than 1000 requests per day and having less than 100 impressions. I am loging the receive, show, close and fail in google analytics, and I noted that there are very many results that fail, I am waiting for the interstitial to be loaded, still, the problem persists.
It seems to be an intermittent problem, since it seems to work perfect in my phone. But in production, I see many fails in the Analytics and low impressions in AdMob. My fill rate is 100%, that means that every time I request an ad, I get one. I know that my impressions will not be exactly the same as the number of request, because I am waiting to show the interstitial and the user can leave the app without seen it, but, according to my Analytics statistics, I should be having many more impressions.
Any help would be welcome.