Resource icon

DFP Integration into Xenforo + Adblock detection

The groups are stored in {$visitor.user_group_id} and {$visitor.secondary_group_ids}

Secondary group IDs spits out a comma separated list, but from my quick googling looks like DFP needs multiple values for a single key to be enclosed by quotes, so you'll need to add the surrounding quotes to each item using either PHP or javascript, and that's not worth my time to figure out the looping syntax right now, so just going to instead use the simpler guest/registered user targeting for now.

My goal was simply to have a list of user groups I could target as it's a lot simpler than adding "member of X group? yes/no" each time I want to add new targeting criteria... if I have a list of integers, I can add a new group in Xenforo, and it's immediately passed to DFP where I can use it when targeting line items without needing to do additional template edits.

One thing I did add to my DFP targeting was preventing adsense from running on certain templates. This goes in your DFP head code. It only works if you run Adsense as a line item dynamic allocation rather than sitewide dynamic allocation because you have to then in DFP target your adsense line items to only compete when "adsense_allowed" equals yes:
Code:
    <xen:comment>
    Adsense TOS prohibits running ads on error, search, login, etc pages
    </xen:comment>
    <xen:if is="in_array({$contentTemplate}, array('message_page', 'error', 'search_form', 'search_form_post', 'search_form_profile_post', 'search_results', 'register_form', 'register_facebook', 'register_twitter', 'register_google', 'login', 'error_with_login', 'contact'))">
        googletag.pubads().setTargeting("adsense_allowed", "no");
    <xen:else />
        googletag.pubads().setTargeting("adsense_allowed", "yes");
    </xen:if>
 
Mapping works well, but I have a problem with the forum targeting. I'm testing a house campaign to show BLUE banners throughout the board in threads. I also have a standard campaign to show RED banners in one forum, let's call it "PORI". A Thread has 2 ad slots, after 5th message and after the thread. The upper slot is for desktop only but the latter one is both for mobile and desktop. Loading the ads with the mapping instructions mentioned here. Problem is:

With desktop in PORI forum:
1) Upper slot has correctly a RED banner.
2) Latter slot has BLUE banner, should be RED.

With mobile it works ok in PORI forum:
1) The latter slot is only displayed and correctly displaying RED banner

The line item targeting forum PORI with RED banners has both ad slots as inventory & the custom targeting for forumid. Those RED banners aren't showing elsewhere so the targeting works at least in that manner. I set the line item for RED banners to deliver as fast as possible, tried with different creative displaying (one or more, as many as possible) with same results. I have 2 creatives, one for desktop and one for mobile. Should I have 2 for destkop to make it work, or? Thanks in advance.
 
These worked for me:

older iPhones, Lumias, etc:
addSize([320, 400], [[300, 250], [300, 300]]).

newer iPhones, bigger smartphones, smaller tablets:
addSize([340, 600], [[336, 280], [300, 250], [300, 300]]).

iPad & bigger tablets portrait: addSize([768, 200], [728, 90]):
bigger tablets landscape & desktop: addSize([1024, 400], [[980, 120], [980, 400]]).
 
Everything is working great except for tablets in landscape mode (iPad @ 1024x768), where it displays a 728x90 ad behind the sidebar. I want it to display a 468x60 ad, since the main section is 662px wide.

upload_2015-7-14_10-35-42.webp


Here's what I have:

var mappingGeneral = googletag.sizeMapping().
addSize([748, 200], [728, 90]).
addSize([488, 200], [468, 60]).
addSize([320, 200], [320, 50]).
build();


Anyone have any clues as to how I can fix this?
 
Sometimes a smaller ad will serve if you have that option selected in DFP if creative for the 1024 slot isn't available on the network.
 
Everything is working great except for tablets in landscape mode (iPad @ 1024x768), where it displays a 728x90 ad behind the sidebar. I want it to display a 468x60 ad, since the main section is 662px wide.

View attachment 111313


Here's what I have:

var mappingGeneral = googletag.sizeMapping().
addSize([748, 200], [728, 90]).
addSize([488, 200], [468, 60]).
addSize([320, 200], [320, 50]).
build();


Anyone have any clues as to how I can fix this?
Sorry, I didn't see your comment until now (since I'm looking through this thread to see what needs revamping...hopefully have an update here shortly). What I think you'll need to do is set the bigger sized ads to only display for desktop. This should fix your issue.
8nlZRIh.png


Actually, it might be smarter to use the drop down and "exclude" all the phones and tablets so it would end up only displaying on desktop. I'm really not sure how that is going to effect ad serving so if you do this, let us know if it fixes your problem.
 
Thanks for the explanation on DFP targeting. Great solution to pass the forum node ID to DFP and serve targetted ads!

Let's say I have two sized, one for responsive and one not. Would it be better to use this sizemapping function or to create two different sized inventory and serve one in <div class="hiddenResponsiveNarrow"> and one in <div class="visibleResponsiveNarrow">.
 
AzzidReign updated DFP Integration into Xenforo + Adblock detection with a new update entry:

Changes to the adblocking code

Changed some formatting to the thread and updated the code for the Adblock message to user.

New code
CSS changes:
Added round borders
Changed background color
Goes in extra.css
CSS:
/* AdBlock Detection */
#tester {
    display:none;
}

.blockContainer { text-align: center; margin: 10px auto; clear: both; }
.noticeContainer { padding: 20px; background: #F76A07; color: #fff; border-radius: 5px; }
.noticeContainer .head { font-size: 22px; font-weight: bold...

Read the rest of this update entry...
 
I'll be looking into possibly making it so that users who ignore or decide to block your message to them about blocking ads, that once they do that, they won't be able to see any of the content on the site. Anyone savvy enough to figure out a way around that, I will just leave them alone lol I'm hoping that it is far and few between. Being the gaming/tech niche, our demographics are much more tech savvy than almost every other niche out there.
 
Top Bottom