XF 1.5 Mobile - Google page-level adsense ads

tommydamic68

Well-known member
Has anyone incorporated these new Google adsense "mobile only" ads? Apparently they do not add to your existing 3 ads per page quota. If so, where would you add the code?

Screen Shot 2016-04-28 at 5.24.35 AM.webp
 
Last edited:
The page_container_js_head template would be a good location for this.
I put it in PAGE_CONTAINER template.
Is it better to put it into page_container_js_head template?
If yes, where exactly?
Code:
    <script src="{$jQuerySource}"></script>   
    <xen:if is="{$jQuerySource} != {$jQuerySourceLocal}">
        <script>if (!window.jQuery) { document.write('<scr'+'ipt type="text/javascript" src="{$jQuerySourceLocal}"><\/scr'+'ipt>'); }</script>
    </xen:if><xen:if is="{$xenOptions.uncompressedJs} == 1 OR {$xenOptions.uncompressedJs} == 3">
    <script src="{$javaScriptSource}/jquery/jquery.xenforo.rollup.js?_v={$xenOptions.jsVersion}"></script></xen:if>   
    <script src="{xen:helper javaScriptUrl, '{$javaScriptSource}/xenforo/xenforo.js?_v={$xenOptions.jsVersion}'}"></script>
<!--XenForo_Require:JS-->
 
It's fine in there, too.
Can anyone ELI5 this? So, exactly what should I do? I see the page_container_js_head listed above under the templates tab. Do I delete whats in there and then copy/paste what Google gives me? The help is very much appreciated.
I apologize in advance for my ignorance in these matters....:(
 
Never delete what's in the existing templates unless you know what you are doing.

Just add it to the end or beginning of that template.
Thanks for the quick reply and the help. I just added the code Google gave me at the end without touching anything else. I just checked via Mobile and didn't see anything pop up but I also checked the Sphynxlair.com mobile website above and nothing popped up on my mobile either so IDK. I know that the Google says they will display at "Optimal Times" so I can just guess that now is not an optimal time. I will keep an eye out. Thanks again for all you do.
 
Thanks for the quick reply and the help. I just added the code Google gave me at the end without touching anything else. I just checked via Mobile and didn't see anything pop up but I also checked the Sphynxlair.com mobile website above and nothing popped up on my mobile either so IDK. I know that the Google says they will display at "Optimal Times" so I can just guess that now is not an optimal time. I will keep an eye out. Thanks again for all you do.
Its random, I see it here and there.
 
Sure! :)


Template: page_container_js_head


You have to insert the followin, replace the ca-pub-XXXXXXXXXXXXXXXX with yours (get this from AdSense).

Code:
<xen:if is="!in_array({$contentTemplate}, array('', 'message_page', 'online_list', 'lost_password_confirm', 'login_two_step', 'forum_list', 'help_index', 'help_smilies', 'help_bb_codes', 'error', 'help_cookies', 'help_terms', 'member_view', 'account_personal_details', 'account_alerts', 'account_likes', 'conversation_list', 'conversation_add', 'conversation_view', 'account_contact_details', 'account_privacy', 'account_preferences', 'account_alert_preferences', 'account_following', 'account_ignored', 'account_external_accounts', 'account_security', 'search_form', 'search_form_post', 'search_form_profile_post', 'lost_password', 'member_notable', 'xengallery_search_form_media', 'search_results', 'register_form', 'login', 'error_with_login', 'contact', 'thread_view', 'register_facebook', 'register_twitter', 'register_google', 'cta_overtaking_index'))">
<xen:if is="!{$visitor.user_id}">   
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-XXXXXXXXXXXXXXXX",
    enable_page_level_ads: true
  });
</script>
</xen:if>
</xen:if>
 
umm ok how do I place

Code:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-XXXXXXXXXXXXXXXX",
    enable_page_level_ads: true
  });
</script>

inside page_container_js_head template but not tell it to show up for specific user groups? EG VIP/Premium Members?

the user group ID I wish for the following code not to show for are 28 & 5

I'm still a n00b when it comes to Xenforo coding.
 
Back
Top Bottom