Adding Adsense Script in

Posted in: Newsmag
Post count: 196

Hello, I am currently with an ad company that uses DFP and when their ads don’t show I have my backup google adsense ads come in. In order for these ads to display, I was told I need to add the following code within the <HEAD>:
<script type='text/javascript'>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
</script>

<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.defineSlot('/158056972/sneakerfiles_300x250_ROS', [300, 250], 'div-gpt-ad-1424368342288-0').addService(googletag.pubads());
googletag.defineSlot('/158056972/sneakerfiles_300x600_ROS', [300, 600], 'div-gpt-ad-1424368342288-1').addService(googletag.pubads());
googletag.defineSlot('/158056972/sneakerfiles_728x90_ROS', [728, 90], 'div-gpt-ad-1424368342288-2').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>

Then in the ad spots I wanted I would ad code like this:
<!-- sneakerfiles_ros_160x600 -->

<div id='div-gpt-ad-1405608165645-0' style='width:160px; height:600px;'>

<script type='text/javascript'>

googletag.cmd.push(function() { googletag.display('div-gpt-ad-1405608165645-0'); });

</script>

</div>

<!-- sneakerfiles_ros_300x250 -->

<div id='div-gpt-ad-1405608165645-1' style='width:300px; height:250px;'>

<script type='text/javascript'>

googletag.cmd.push(function() { googletag.display('div-gpt-ad-1405608165645-1'); });

</script>

</div>

<!-- sneakerfiles_ros_728x90 -->

<div id='div-gpt-ad-1405608165645-2' style='width:728px; height:90px;'>

<script type='text/javascript'>

googletag.cmd.push(function() { googletag.display('div-gpt-ad-1405608165645-2'); });

</script>

</div>

I can’t seem to find the <HEAD> tag. I looked in header, but it’s just one line of code (in Child theme) same for the non-child theme.

Even if I add the top piece of code with one of the bottom in the ad panel under themes, they don’t display. How can I achieve this?

Thanks,

Post count: 7909

Hi,

Please try to add it like this in the header.phphttp://screencast.com/t/XHpJCgkKU3
And then use the other codes in Ads section from Theme Panel for example: http://screencast.com/t/DoGTPa1V4a

Thanks!

Post count: 196

Hello, so when I open the header.php in the child or regular theme, the only thing that’s in it is the following: > itemscope=”itemscope” itemtype=”://schema.org/WebPage”>

Post count: 7909

Hi,

I’m not sure where you looking for header.php, the file is in the root of the theme: http://screencast.com/t/XgXMd5oBiqs

Thanks!

Post count: 196

I was looking in the child theme and regular theme, the header.php file is the exact same with the only line of code:

> itemscope="itemscope" itemtype="://schema.org/WebPage">

Post count: 196

Hmm that’s weird. I was opening the header.php with text edit on Mac and that was the only code that showed up. When I open the file with XCode, it shows everything…very odd. Needless to say I see it now, thank you once again.

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newsmag’ is closed to new topics and replies.