Forum Moderators: phranque

Message Too Old, No Replies

Creating a passback with Google Ad Manager

         

csdude55

5:38 pm on Jul 19, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm tentatively working with ad.plus; I know, they have a lot of bad reviews! But I've noticed a lot of those reviews have similar spelling and grammar errors, which makes me think there're a lot of fake reviews. They said that they've recently been approved to be a Certified Publishing Partner, so I'm sending a small number of impressions their way for testing until that can be confirmed.

One big advantage with them, though, is that they use Google Ad Manager. Which gives me a little more flexibility with the ads than I've had with other companies.

A negative, though, is a low fill rate! Yesterday, the ad unit I gave them that usually has 30,000 impressions /day only had 12,000 impressions.

Here's an example of the ad unit code:

// where "12345" represents my Ad Manager ID
googletag.cmd.push(function() {
googletag.defineSlot('/21849154601,12345/Ad.Plus-300x250', [300, 250], 'atf_unit')
.addService(googletag.pubads());
googletag.enableServices();
googletag.display('atf_unit');
});


How do I make this pass back to my Adsense account when they don't have an ad to fill it?

Better yet, is there a way to make them compete against one another and return the highest payer?

csdude55

5:55 pm on Jul 19, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Minor update, maybe I'm using the wrong phrase when I say "passback"?

I keep finding articles saying to simply wrap the code in <div id="gpt-passback">, and then change the "atf_unit" ID to "gpt-passback". But that can't possibly do what I'm wanting, because:

1. I have 4 ads on the page, and they can't all have the same ID; and

2. it doesn't define what to pass back to.

In case "passback" means something different than I think, my goal here is to make it start with ad.plus, and if nothing is available then try Adsense. Ideally, if nothing is there, either, then it would default to a PHP script on my end where I show a direct-sell ad.

csdude55

7:57 pm on Jul 20, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just talking to myself here (haha), but I've learned a few things.

In this line:

googletag.defineSlot('/21849154601,12345/Ad.Plus-300x250', [300, 250], 'atf_unit')]/code]

the [i],12345[/i] defines the passback Ad Manager account. That much makes sense.

But beyond that? I have no idea. I [i]think[/i] that the ad unit on their end is named "Ad.Plus-300x250", so do I need to create the same ad unit in my Ad Manager?

I also came across a setting that claims to be important, but it doesn't appear to have had an impact for me. I modified this line:

[code].addService(googletag.pubads());


to include "page_url", like so:

$URL = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

.addService(googletag.pubads()
.set('page_url', '$URL')
);


What I read was that the passback would open in an IFRAME, so you needed this for the passback to recognize the actual URL of the source. It hasn't solved my problem, but maybe it will be relevant later?

csdude55

5:05 am on Jul 25, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have found no way to create a real passback with GAM. I'm pretty annoyed with it... I keep reading "you can easily create a floor and a passback if it's below the preset amount", but nothing says HOW to do this! I think maybe it's something that existed in the past and is no longer real.

But anyway, I have created a workaround. At the bottom of the page:

<!-- in my case, this is already at the top so it's not necessary again -->
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
// same here; this is defined at the top so it's not actually needed here again
window.googletag = window.googletag || {cmd: []};

// trigger this 500ms after the document is complete
var interval = setInterval(function() {
if (document.readyState === 'complete') {
clearInterval(interval);
altFunc();
}
}, 500);

function altFunc() {
var i, unit;

for (unit in ['atf_unit', 'btf_unit']) {
if (
(i = document.getElementById(unit)) &&
i.style.display !== 'none' &&

// my active ad units have at least 300px width set in CSS, so if it's
// under 300px then ignore it
i.clientWidth > 200 &&

// if the height isn't greater than 50px then it must be empty
i.clientHeight < 50) {

// my Ad Manager ID
var slot = '/12345/',
size;

googletag.cmd.push(function() {
googletag.pubads().collapseEmptyDivs();

// atf
if (unit === 'atf_unit') {
slot += '300x250_ATF_Adsense';
size = '[[300, 600], [300, 250]]';
}

// btf
if (unit === 'btf_unit') {
slot += '300x250_BTF_Adsense';
size = '[[300, 600], [300, 250]]';
}

googletag.defineSlot(slot, size, unit)
.addService(googletag.pubads()

// no idea if this helps, but it doesn't hurt
.set('page_url', '{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}')
);

googletag.pubads().enableSingleRequest();
googletag.enableServices();

googletag.display(unit);
});
}
}
}


I just began running this tonight, and it appears to be working well :-) In theory, I could wait another 3 seconds or so and check if it's empty again, and if so then fill with a default.

Do you see any problems with using this as a hand-rolled passback? Last thing I need is Adsense slapping me around for it!

csdude55

9:25 pm on Jul 25, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well, sumpin's not right. It shows the ads from the passback as expected, but they're not showing up in my Ad Manager report or in Adsense.

It really shouldn't be this complicated :-/

csdude55

8:24 pm on Jul 31, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I figured out the problem, the "size" variables can't be in quotes!

I finally got it working, but with poor results. When I plugged in GAM as the backup it increased my revenue by about $0.02 /day, but then I changed it to plug in Adsense and it increased by $20! I don't know if I did something wrong; the ads were showing and the reports showed a good fill rate, but low ad impressions and clicks.

I think I'll create a new thread with the final code for both GAM as a backup and then Adsense as a backup. Maybe it'll help people doing this same thing in the future and save them 2 weeks of work :-/