How do I setup DFP GPT ad slot for multiple ad placements on same page? - adsense

I am new to Google Ad Manager (DFP) and need little help in setting up structuring my DFP inventory and implement it on page. CONSIDERING my website is a small news website, I've 5 sections of my website - World/Business/Politics/Entertainment/Sports. and every section has atleast 3-5 ad placements including some placements with same size i.e. sports section has two 300x250 placement whereas politics section has three 728x90 placements.
The approach I've taken was creating five ad slots in DFP as following -
/12345678/website.com/world
/12345678/website.com/sports
/12345678/website.com/business
/12345678/website.com/entertainment
/12345678/website.com/politics
Now the bigger challenge I am facing here to determine, should I call
googletag
.defineSlot('/12345678/website.com/sports',
[[300, 250], [728, 90], [300, 250]], 'div-gpt-sports12345')
.addService(googletag.pubads());
Will my page body be coded as -
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
window.googletag = window.googletag || {cmd: []};
googletag.cmd.push(function() {
googletag.defineSlot('/21871128741/teststack', [[300, 250]], 'div-mrec1').addService(googletag.pubads());
googletag.defineSlot('/21871128741/teststack', [[300, 250]], 'div-mrec2').addService(googletag.pubads());
googletag.defineSlot('/21871128741/teststack', [[728, 90]], 'div-lb728x90_1').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
<!-- /21871128741/teststack/300x250 -->
<div id='div-mrec1' style='width: 300px; height: 250px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-mrec1'); });
</script>
</div>
<!-- /21871128741/teststack/300x250 -->
<div id='div-mrec2' style='width: 300px; height: 250px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-mrec2'); });
</script>
</div>
<!-- /21871128741/teststack/300x250 -->
<div id='div-lb728x90_1' style='width: 728px; height: 90px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-lb728x90_1'); });
</script>
</div>
I've also tried another version by calling the gpt ad slot using thier unique child ad units .
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
window.googletag = window.googletag || {cmd: []};
googletag.cmd.push(function() {
googletag.defineSlot('/21871128741/teststack/mrec1', [[300, 250]], 'div-mrec1').addService(googletag.pubads());
googletag.defineSlot('/21871128741/teststack/mrec2', [[300, 250]], 'div-mrec2').addService(googletag.pubads());
googletag.defineSlot('/21871128741/teststack/lb728x90_1', [[728, 90]], 'div-lb728x90_1').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
<!-- /21871128741/teststack/300x250 -->
<div id='div-mrec1' style='width: 300px; height: 250px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-mrec1'); });
</script>
</div>
<!-- /21871128741/teststack/300x250 -->
<div id='div-mrec2' style='width: 300px; height: 250px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-mrec2'); });
</script>
</div>
<!-- /21871128741/teststack/300x250 -->
<div id='div-lb728x90_1' style='width: 728px; height: 90px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-lb728x90_1'); });
</script>
</div>

Regarding your needs, you have to define multiple slots for the same page :
banner = [728, 90]
mpu1 = [300,250]
mpu2 = [300,250]
Each defined slot is linked to a div ID (as detailed here) :
googletag.Slot googletag.defineSlot(adUnitPath, size, opt_div)
where :
adUnitPath /string/ : Full ad unit path with the network code and unit code.
size /array/ : Width & Height of the sizes allowed to be call in this slot
opt_div /string/ : ID of the div that will contain this ad unit.
In your code sample, you try to use the same div ID 3 times in the same DOM, and you only declare one adslot... What you should do is more something like :
//banner definition
googletag.defineSlot('/12345678/website.com/sports',[[728, 90]], 'div-banner').addService(googletag.pubads());
//mpu1 definition
googletag.defineSlot('/12345678/website.com/sports',[[300, 250]], 'div-mpu1').addService(googletag.pubads());
//mpu2 definition
googletag.defineSlot('/12345678/website.com/sports',[[300, 250]], 'div-mpu2').addService(googletag.pubads());
In this case, the adserver will generate 3 adcalls (one for each placement defined and displayed).
To make sure you will we able to include or exclude one of the mpus on the page, you could add key-values such as :
banner = [728, 90]
mpu1 = [300,250], position = 1
mpu2 = [300,250], position = 2
To do so, you will have to setTargetings on each mpu slot (here for details) :
//mpu1 definition
googletag.defineSlot('/12345678/website.com/sports',[[300, 250]], 'div-mpu1').setTargeting('position', '1').addService(googletag.pubads());
//mpu2 definition
googletag.defineSlot('/12345678/website.com/sports',[[300, 250]], 'div-mpu2').setTargeting('position', '2').addService(googletag.pubads());

Related

Cell in ag-grid not clickable using a tags

I have 3 columns in an ag-grid (version 23.2.0). First column and third column should be clickable to a modal.
The 3rd column has a FA pencil and works fine.
The 1st column has a name. The name is displayed but there is no clickable behavior.
I have included the code below:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="Components" content="">
<meta name="Bryan Schmiedeler" content="">
<link rel="icon" href="../../favicon.ico">
<link rel="canonical" href="https://getbootstrap.com/docs/3.4/examples/navbar-fixed-top/">
<!-- Latest compiled and minified Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<!-- jQuery-->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<!-- Popper.js, -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<!-- Bootstrap.js, -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- ag-Grid.js, -->
<script src="https://unpkg.com/#ag-grid-enterprise/all-modules#23.2.0/dist/ag-grid-enterprise.min.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var columnDefs = [
{headerName: "Trucker Name", field: "name",cellRenderer: 'activateCellRenderer2', width:250, colSpan: function(params) {
return params.data === 2 ? 3 : 1;
},},
{headerName: "Businesses", field: "model", minWidth: 200,
maxWidth: 350, flex: 2,},
{headerName: "Actions", field: "price",type:"rightAligned", cellRenderer: 'activateCellRenderer',flex: 1}
];
// specify the data
var rowData = [
{name: "Ben Christy", model: "Salina", price: "A"},
{name: "Cindy Blideman", model: "Pratt", price: "I"},
{name: "Wes Woodson", model: "Waverly", price: "A"},
{name: "Bryan Schmiedeler", model: "Overland Park", price: "A"}
];
// let the grid know which columns and what data to use
var gridOptions = {
defaultColDef: {
resizable: true
},
columnDefs: columnDefs,
domLayout: 'autoHeight',
components: {
'activateCellRenderer': ActivateCellRenderer,
'activateCellRenderer2': ActivateCellRenderer2
},
rowData: rowData,
};
// cell renderer class
function ActivateCellRenderer() {
}
// init method gets the details of the cell to be renderer
ActivateCellRenderer.prototype.init = function(params) {
this.eGui = document.createElement('div');
this.eGui.innerHTML = '<a data-toggle="modal" href="#myModal">\
<i class="fa fa-pencil"</i>\
</a>'
};
ActivateCellRenderer.prototype.getGui = function() {
return this.eGui;
};
// cell renderer class
function ActivateCellRenderer2() {
}
// init method gets the details of the cell to be renderer
ActivateCellRenderer2.prototype.init = function(params) {
this.eGui = document.createElement('div');
this.eGui.innerHTML = '<a data-toggle="modal" href="#myModal">'; this.eGui.innerHTML += params.value;
this.eGui.innerHTML += '</a>';
};
ActivateCellRenderer2.prototype.getGui = function() {
return this.eGui;
};
document.addEventListener('DOMContentLoaded', function() {
var gridDiv = document.querySelector('#myGrid');
new agGrid.Grid(gridDiv, gridOptions);
});
</script>
</head>
<body>
<div class = "container"; style= "width: 100%";>
<div class = "row">
<div id="myGrid" class="ag-theme-alpine" style="width: 100%";></div>
</div>
</div>
<body>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<script src="../../dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
JS is not happy with the way you are building innerHTML. If you do not close the tag in one line then JS will do it for you and will ignore any matching closing tag it encounters later.
do it this way and cell will render like link and will be clickable.
this.eGui.innerHTML = '<a data-toggle="modal" href="#myModal">' + params.value + '</a>';
here is a fiddle containing your code snippet.
https://jsfiddle.net/dnfb0wop/
also check out this image explaining innerHTML fiasco.

google column chart make it responisve

Good day, I have a google column chart and work perfectly but when I re size my browser the column chart overflowed and wont re size. my website is responsive and I dont want to put my bar chart like that. how to get my column chart responsive?
I got this column chart from developers.google.com/chart/interactive/docs/gallery/columnchart
here is the code
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title><?php echo $title;?></title>
<!-- Load Google chart api -->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses', 'Profit'],
['2014', 1000, 400, 200],
['2015', 1170, 460, 250],
['2016', 660, 1120, 300],
['2017', 1030, 540, 350]
]);
var options = {
chart: {
title: 'Company Performance',
subtitle: 'Sales, Expenses, and Profit: 2014-2017',
},
bars: 'vertical',
vAxis: {format: 'decimal'},
height: 400,
colors: ['#1b9e77', '#d95f02', '#7570b3']
};
var chart = new google.charts.Bar(document.getElementById('chart_div'));
chart.draw(data, google.charts.Bar.convertOptions(options));
var btns = document.getElementById('btn-group');
btns.onclick = function (e) {
if (e.target.tagName === 'BUTTON') {
options.vAxis.format = e.target.id === 'none' ? '' : e.target.id;
chart.draw(data, google.charts.Bar.convertOptions(options));
}
}
}
</script>
</head>
<body>
<div id="chart_div" style="width:100%;"></div>
<br/>
<div id="btn-group">
<button class="button button-blue" id="none">No Format</button>
<button class="button button-blue" id="scientific">Scientific Notation</button>
<button class="button button-blue" id="decimal">Decimal</button>
<button class="button button-blue" id="short">Short</button>
</div>
</body>
</html>
I tried also to add width="100%" from div but its doesn't work at all.
Currently, the problem with Google Charts is that it doesn't have a responsive feature.
From previous explorations over the web, the best solution that I found and implemented was:
$(window).resize(function () {
drawChart();
});
This piece of code calls the drawChart() function each time the browser window is resized. Therefore, this means that the Chart is redrawn each time. This may not be the best or efficient solution, but for me it did the job.
In order to allow the .resize() function, you will require the jQuery Library. More information for this is available here.

DoubleClick for Publishers "Ad unit did not render."

As I am completely newbie this issue will be probably an easy one for others.
My ads are not displayed on the web (various banners, multiple places, none shown).
On the www.motoraport.pl/stacje I expect 2 banners to be displayed on the right, but the slots are empty.
When debugging I get an info like
MRPrawa1
Slot size: 300x250Format: DivService: DFP
Ad unit did not fetch.
Ad unit did not render.
Ad fetch count: 1
Iframe type: none
Warnings:
Ad unit failed to fetch.
-or-
MRPrawa1
Slot size: 300x250Format: DivService: DFP
251 ms to fetch creative
Ad unit did not render.
Ad fetch count: 1
Iframe type: none
However if I click in the debug console Open Creative in New Window I see the banner images.
I thought there could have been a code mess up so I created simple localhost page
<!DOCTYPE html>
<html>
<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);
})();
googletag.cmd.push(function() {
googletag.defineSlot('/19844765/MRPrawa1', [300, 250], 'div-gpt-ad-1450140062768-3').addService(googletag.pubads());
googletag.defineSlot('/19844765/MRPrawa2', [300, 250], 'div-gpt-ad-1450140062768-4').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.pubads().enableSyncRendering();
googletag.enableServices();
});
</script>
</head>
<body>
<!-- MRPrawa1 -->
<!-- /19844765/MRPrawa1 -->
<div id='div-gpt-ad-1450140062768-3' style='height:250px; width:300px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1450140062768-3'); });
</script>
</div>
<!-- /19844765/MRPrawa2 -->
<div id='div-gpt-ad-1450140062768-4' style='height:250px; width:300px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1450140062768-4'); });
</script>
</div>
</body>
</html>
But the problem remains. Anybody could help?
After a couple days of pissing in the wind I accidentally discovered that all ad slots that are declared in <head/> must be implemented in <body/>.
In my case there were primarily 5 slots declared in head and 1-2 used in body depending on page.
Somehow this caused that all ads came up blank.
I hope this will help others to get through embedding DFP ads.

Jssor non-jquery slider dynamic amount multiple slider on one page

How can I put dynamic amount multiple slider on a single page? I could use 2 sliders on a page as follows:
<script>
jssor_sliderb_starter1 = function (containerId) {
...
};
jssor_sliderb_starter2 = function (containerId) {
...
};
<div id="sliderb_container1">
...
<script>
jssor_sliderb_starter1('sliderb_container1');
</script> </div>
<div id="sliderb_container2">
...
<script>
jssor_sliderb_starter2('sliderb_container2');
</script> </div>
But what if I dont know the amount of the sliders? Please help..
I have added 4 identical sliders on my page with different images and captions and used the following code and it works fine.
<!-- Jssor Sliders -->
<script>
jssor_sliderb_starter = function (containerId) {
...
};
</script>
<!-- Jssor Slider Begin -->
<div id="sliderb_container1" class="sliderb_con">
...
<script>
jssor_sliderb_starter('sliderb_container1');
</script>
</div>
<div id="sliderb_container2" class="sliderb_con">
...
<script>
jssor_sliderb_starter('sliderb_container2');
</script>
</div>
<div id="sliderb_container3" class="sliderb_con">
...
<script>
jssor_sliderb_starter('sliderb_container3');
</script>
</div>
<div id="sliderb_container4" class="sliderb_con">
...
<script>
jssor_sliderb_starter('sliderb_container4');
</script>
</div>
<!-- Jssor Slider End -->
So now if I add more sliders i will have to use different ids only. I was confused about how to use the ids to call the function and thought i have to write different functions for each slider. But the code worked. Thank You :)
<!-- Jssor Sliders -->
<script>
jssor_sliderb_starter = function (containerId) {
}
</script>
<div id="sliders">
<!-- Jssor Slider Begin -->
<div class="sliderb_con">
</div>
<div class="sliderb_con">
</div>
<div class="sliderb_con">
</div>
<div class="sliderb_con">
</div>
<!-- Jssor Slider End -->
</div>
<script>
var slidersElement = document.getElementById("sliders");
for (var tmpEl = slidersElement.firstChild; tmpEl; tmpEl =tmpEl.NextSibling) {
if (tmpEl.nodeType == 1) {
jssor_sliderb_starter(tmpEl);
}
}
</script>

Need Infinitescroll to work with a simple Masonry tumblr

Not sure what I'm doing wrong. The Masonry works, but the Infinite Scroll doesn't.
I'm trying to make the simplest Masonry/InfiniteScroll theme to build upon. I've tried a lot of different methods but I still get stuck.
<title>{title}</title>
<meta name="description" content="{MetaDescription}" />
<link rel="shortcut icon" href="{Favicon}">
<!--[if IE]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://static.tumblr.com/wgijwsy/Ebfm2v4gy/jquery.masonry.min.js"></script>
<script type="https://github.com/paulirish/infinite-scroll/blob/master/jquery.infinitescroll.min.js"></script>
<script type="text/javascript">
$(window).load(function () {
var $content = $('#container');
$content.masonry({itemSelector: '.item', columnWidth:300
});
$content.infinitescroll({
navSelector : 'div#pagination',
nextSelector : 'div#pagination a#nextPage',
itemSelector : '.item'
});
});
</script>
<style>
.item{width:300px;}
img{max-width:100%;}
</style>
</head>
<body>
<div id="container">
{block:Posts}
{block:Photo}
<div class="item"><img src="{PhotoUrl-500}" title="{PhotoAlt}"/></div>
{/block:Photo}
{/block:Posts}
</div><!--wall-->
{block:Pagination}
<div id="pagination">
{block:NextPage}
<a id="nextPage" href="{NextPage}"></a>
{/block:NextPage}
{block:PreviousPage}
{/block:PreviousPage}
</div>
{/block:Pagination}
{/block:IndexPage}
</div>
</body>
</html>
Perhaps you could use this code if you want, this is the best one i have found so far:
<script type="text/javascript" src="http://static.tumblr.com/dbek3sy/iBElrgjim/jquerymasonry.js"></script>
<script type="text/javascript" src="http://static.tumblr.com/dbek3sy/Qyblrgjfn/jqueryinfintescroll.js"></script>
<script type="text/javascript">
$(window).load(function(){
var $wall = $('.posts');
$wall.imagesLoaded(function(){
$wall.masonry({
itemSelector: '.entry',
isAnimated : false
});
});
$wall.infinitescroll({
navSelector : "div#navigation",
nextSelector : "div#navigation a#nextPage",
itemSelector : ".entry",
bufferPx : 2000,
debug : false,
errorCallback: function() {
$('#infscr-loading').fadeOut('normal');
}},
function( newElements ) {
var $newElems = $( newElements );
$newElems.hide();
$newElems.imagesLoaded(function(){
$wall.masonry( 'appended', $newElems,{isAnimated: false}, function(){$newElems.fadeIn('slow');} );
});
}); $('.posts').show(500);
});
</script>
<script>
$.fn.changebackgroundColor = function(msg) {
$("#perma").css("#000");
};
</script>
I have no issue with the infinite scroll with it and it's rather simple. You should just check the Selector and var names to put those that are in your theme. else than that, I think the problem could be the scripts you are using. Try to use different ones maybe. I used to have some similar to yours and I realized that they didn't even respond when i debugged my page. It could be a similar issue.