これが私のシナリオです。DFP で次のカスタム ターゲティング条件を定義しています。
- キー: smag-lps。値は、広告のランディング ページをターゲットにするために WordPress で照合される静的なページ名です。
- キー: 投稿 ID、値 - ユーザーは投稿の ID を入力して、広告の投稿をターゲティングできます。
目標は、広告の作成時に選択されるページ名または投稿 ID のいずれかをターゲティングする DFP 広告を配信することです。私のWordPressテーマでheader.phpを試しました:
<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.pubads().set("adsense_background_color", "FFFFFF");
});
</script>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.defineSlot('/2152723/SM-Leaderboard1', [728, 90], 'div-gpt-ad-1366056066154-0').addService(googletag.pubads());
.addService(googletag.pubads())
.setTargeting("smag-lps", "<?php echo get_current_page(); ?>")
.setTargeting("postid", "<?php echo get_the_ID(); ?>");
googletag.defineSlot('/2152723/SM-Leaderboard2', [728, 90], 'div-gpt-ad-1366056066154-1').addService(googletag.pubads());
.addService(googletag.pubads())
.setTargeting("smag-lps", "<?php echo get_current_page(); ?>")
.setTargeting("postid", "<?php echo get_the_ID(); ?>");
googletag.pubads().enableSingleRequest();
googletag.enableServices();
};
</script>
php echoを使用して現在のページまたはIDを取得しようとすると、サイトがタンクに入れられます。私が間違っていることについて何か提案はありますか?
-M