jeffwidman
Active member
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:
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>