XF 1.5 Where to paste initial Adsense code?

Jim Fox

Active member
I just signed up for Google AdSense, and I was given some code to copy and paste in my website, it says between the <head> and </head> tags. I searched in the templates and could not find either tag. If the syntax is different in Xenforo, what tags should I be looking for and which template would this be in?

The code I have to paste is:

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

Thanks,

Jim
 
i tried it in ad template but unfortunately, twice my adsense account got rejected. Then i put that code in page container template and in 2 days got approval.

It may not have nothing to do with that, but as i got rejection twice and acceptance when put in page container. I thought better to put it in their.

After approval i removed that code and for showing ad i put it in ad template and given position what i wanted.

As per google adsense that code need to be put in between head to head tag.
 
i tried it in ad template but unfortunately, twice my adsense account got rejected. Then i put that code in page container template and in 2 days got approval.

It may not have nothing to do with that, but as i got rejection twice and acceptance when put in page container. I thought better to put it in their.

After approval i removed that code and for showing ad i put it in ad template and given position what i wanted.

As per google adsense that code need to be put in between head to head tag.

That's not true and it had nothing to do with that. I signed up for an adsense account and placed it in the ad template and got approved without any problem at all.
 
That's not true and it had nothing to do with that. I signed up for an adsense account and placed it in the ad template and got approved without any problem at all.
This. I had no problems at all either.

As per google adsense that code need to be put in between head to head tag.
It is if you put it in the ad templates. Check the page source of your site (assuming the code is now only in the adsense templates, if not check mine). You'll see from the page source that the code does appear in between the head tags.
 
i tried it in ad template but unfortunately, twice my adsense account got rejected. Then i put that code in page container template and in 2 days got approval.

It may not have nothing to do with that, but as i got rejection twice and acceptance when put in page container. I thought better to put it in their.

After approval i removed that code and for showing ad i put it in ad template and given position what i wanted.

As per google adsense that code need to be put in between head to head tag.

Thanks so much, I looked in the Page Container Template and found the <header> and </header>

Because this code has to do with my website getting approved for AdSense in the first place.

From the other links it looks like that is help for once (I hope) get approved and where to then place that code which I am guessing is different then this?
 
It doesn't need to be posted there.

All Adsense code can be pasted into the ad templates that you are using.

More info on using Adsense in the ad templates here:

https://xenforo.com/community/resources/responsive-adsense.2084/
https://xenforo.com/community/resources/responsive-adsense.2084/updates#resource-update-5334

Thanks so much Martok! I will look at those resources. Since I am a noob with AdSense, I just needed some direction on where to paste this first code which I am guessing Google is just reading for the approval process. Once I get approved, then I can use those other links as I will need help on how to place the actual ads on the website.
 
That's not true and it had nothing to do with that. I signed up for an adsense account and placed it in the ad template and got approved without any problem at all.
Thanks Brad, I had placed the code first in the Adheader Template. But wasn't sure if that was right. I did now place it in the PageContainer template as that was easy to find the <header> tag. Hopefully that will work so I get approved.
 
Thanks Brad, I had placed the code first in the Adheader Template. But wasn't sure if that was right. I did now place it in the PageContainer template as that was easy to find the <header> tag. Hopefully that will work so I get approved.
As I said in my previous post and was reiterated by @Brad Padgett, you do not need to put it in the PageContainer template. The code should go in the ad templates. As I also said in my previous post, doing this automatically puts the Adsense code between the head tags (as can be seen from my site). So please follow our advice regarding placement, not the incorrect advice that was given.
 
As I said in my previous post and was reiterated by @Brad Padgett, you do not need to put it in the PageContainer template. The code should go in the ad templates. As I also said in my previous post, doing this automatically puts the Adsense code between the head tags (as can be seen from my site). So please follow our advice regarding placement, not the incorrect advice that was given.

So putting it in the Ad_header Template is a good place? Where it says in the Template to place Ad code below this comment?
 
You use whichever ad templates that you want your adverts to appear in.

Here's a visual guide to the ad locations and their associated ad templates:

https://xenforo.com/community/resources/visual-list-of-ad-locations.1383/

Oh that's helpful!

So that code that Google gave me to paste into the forum doesn't have anything to do with my getting approved? Does that code actually place a Google Ad then where I paste the code?

Since I had just signed up and was waiting for approval, I thought that code had to do with the approval process and wasn't the actual code to call an Ad.

Thanks for being so helpful, this advertising is all new to me.
 
The code will show adverts and they will be attributed to your Adsense account as the google_ad_client code is unique to you.

Adverts won't show up immediately, it takes a little while before this happens (due to approval etc).
 
Top Bottom