这更多地与 javascript 相关,而不是 DFP,但以下内容应该允许您测试不同的关键字组合......
加载此页面,在 URL 中使用逗号分隔的键和值,如下所示:http:
//yoursite.com/ ?key=test&values= test 1,test 2,test 3
<html>
<head>
<title>DFP test</title>
<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">
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results == null) {
return "";
} else {
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
}
var key = getParameterByName('key');
var values = getParameterByName('values').split(',');
googletag.cmd.push(function() {
slot = googletag.defineSlot('/11589435/serptest300x250', [300, 250], 'adunit').addService(googletag.pubads()).setTargeting(key,values);
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>
<body>
<div id="adunit">
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('adunit');
});
</script>
</div>
</body>
</html>