1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 I want to put adsense on my site.

Discussion in 'Styling and Customization Questions' started by Lee123456789, Dec 2, 2013.

  1. Lee123456789

    Lee123456789 Member

    I am new to this and my adsense acount is not fully active, but they want me to add the code snippit before I can be fully approved.
    I created a responsive ad slot using google adsense and open the template Below Top Breadcrumb,
    and pasted the code from google there.
    this has created a blank place holder which is correct I think as I am not yet approved?

    so my questions are
    1. Have I done the first part correct?
    2. How can I make it so that only guests see the ad? (the placeholder is present even for admin).

    hope someone can help me out!

    thanks in advance
     
  2. Lee123456789

    Lee123456789 Member

    oh and here is the code i used!
    Code:
    <xen:hook name="ad_below_top_breadcrumb" />
    <style>
    .guest-ads-top { width: 320px; height: 50px; }
    @media(min-width: 500px) { .guest-ads-top { width: 468px; height: 60px; } }
    @media(min-width: 800px) { .guest-ads-top { width: 728px; height: 90px; } }
    </style>
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- Guest  Ads Top -->
    <ins class="adsbygoogle guest-ads-top"
        style="display:inline-block"
        data-ad-client="ca-pub-7863887970724476"
        data-ad-slot="1618849548"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
     
  3. Brogan

    Brogan XenForo Moderator Staff Member

    Use a conditional statement to show it to guests only.

    My signature has a link to a resource for that.
    I have also written an AdSense resource.
     
  4. Lee123456789

    Lee123456789 Member

    thanks I will bookmark that.....but if you dont mind as I have only been at this a week!!!

    is this correct?

    Code:
    <xen:hook name="ad_below_top_breadcrumb" />
    <xen:if is="!{$visitor.user_id}">
    <style>
    .guest-ads-top { width: 320px; height: 50px; }
    @media(min-width: 500px) { .guest-ads-top { width: 468px; height: 60px; } }
    @media(min-width: 800px) { .guest-ads-top { width: 728px; height: 90px; } }
    </style>
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- Guest  Ads Top -->
    <ins class="adsbygoogle guest-ads-top"
        style="display:inline-block"
        data-ad-client="ca-pub-7863887970724476"
        data-ad-slot="1618849548"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    </xen:if>
     
  5. Lee123456789

    Lee123456789 Member

    that code did not work!!! it was putting <xen:hook name="ad_below_top_breadcrumb" /> in the slot so i did this and it seems to be working!
    I just hope I have not done something that will stop google being able to pipe the ads in!!!

    Code:
    <xen:comment>
    <xen:hook name="ad_below_top_breadcrumb" />
    </xen:comment>
    <xen:if is="!{$visitor.user_id}">
    <style>
    .guest-ads-top { width: 320px; height: 50px; }
    @media(min-width: 500px) { .guest-ads-top { width: 468px; height: 60px; } }
    @media(min-width: 800px) { .guest-ads-top { width: 728px; height: 90px; } }
    </style>
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- Guest  Ads Top -->
    <ins class="adsbygoogle guest-ads-top"
        style="display:inline-block"
        data-ad-client="ca-pub-7863887970724476"
        data-ad-slot="1618849548"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    </xen:if>
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    The hook line is irrelevant, it has no effect on the rest of the code in the template.
    It's just for developers to "hook" into.
     
  7. Lee123456789

    Lee123456789 Member

    so I guess I just have to wait and see the ads start to arrive!

    thanks for your help Brogan, I am sure you are extremly busy!
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    You can see if the code is correct by using a browser inspection tool.

    But yes, it can take an hour or so for ads to start being served.
     

Share This Page